#1 - Missing package?
You're probably missing the package that contains ssh-askpass
. Try installing it.
Fedora/CentOS/RHEL:
$ sudo yum install openssh-askpass
Debian/Ubuntu:
$ sudo apt-get install ssh-askpass-gnome ssh-askpass
Finding missing utilities
You can search for missing tools using these commands:
Fedora/CentOS/RHEL:
$ yum search ssh-askpass
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
======================================================= Matched: ssh-askpass =======================================================
x11-ssh-askpass.x86_64 : A passphrase dialog for X and not only for OpenSSH
ksshaskpass.x86_64 : A KDE version of ssh-askpass with KWallet support
connect-proxy.x86_64 : SSH Proxy command helper
openssh-askpass.x86_64 : A passphrase dialog for OpenSSH and X
Debian/Ubuntu:
$ apt-file -l search ssh-askpass
app-install-data
cruft
git-cola
luckybackup-data
pssh
sdm-terminal
seahorse
ssh-askpass
ssh-askpass-fullscreen
ssh-askpass-gnome
#2 - Disconnected terminal?
I missed this initially but after further reading up I noticed this comment in the man page of ssh
regarding the SSH_ASKPASS
environment variable.
excerpt
SSH_ASKPASS If ssh needs a passphrase, it will read the passphrase from the
current terminal if it was run from a terminal. If ssh does not
have a terminal associated with it but DISPLAY and SSH_ASKPASS
are set, it will execute the program specified by SSH_ASKPASS
and open an X11 window to read the passphrase. This is particularly
useful when calling ssh from a .xsession or related script.
(Note that on some machines it may be necessary to redirect the
input from /dev/null to make this work.)
If you notice in the comment, it states that ssh "doesn't have a terminal associated" AND DISPLAY
& SSH_ASKPASS
are set. Noticing this is key. So to get ssh
to use SSH_ASKPASS
we need to get ssh
to not have a terminal (aka. STDIN
& STDOUT
) attached to it.
One way to do this by making use of the command setsid
. Don't feel bad. I never heard of this tool either. From the man page:
setsid - run a program in a new session
So if we run ssh
as the "program" to setsid
we can detach ssh
from our terminal meeting the criteria mentioned in ssh
's man page. The other criteria are set as follows:
$ echo $DISPLAY; echo $SSH_ASKPASS
:0.0
/usr/libexec/openssh/ssh-askpass
So if we put this all together:
$ setsid ssh user@remotehost
For example:
$ setsid ssh user@skinner

A solution
If you'd like to make it so that the setsid
is "built-in" you can create an aliases like so:
$ alias ssh="setsid ssh"
Now when you ssh
you'll get the GUI popping up asking for your password:
$ ssh user@skinner
References
setsid ssh
instad of plainssh
. – gioele Jul 23 '13 at 08:16ssh
with aliasessetsid ssh
is one approach. There are other ways. The limiting factor is openssh needs no TTY attached in order to activate the ASK_SSHPASS. – slm Jul 23 '13 at 09:08setsid
and then work inssh
from my terminal. That's just not a valid answer at all!? Plus, it was working in older versions of Ubuntu, so I'm not too sure I understand why it suddenly stopped working! – Alexis Wilke Nov 30 '14 at 05:40~/.ssh
so I decided to move them under~/.ssh/other_keys
. That works in the sense that it does let you connect to servers properly, but that hides the keys from thessh-agent
so they do not get auto-added. Moving a key back to~/.ssh
solves the problem, although a better solution would be to have a tool that auto-adds keys without asking for the passphrase... (likessh-add keyname
but silent.) – Alexis Wilke Nov 30 '14 at 23:16ssh-add
not being able to add keys without immediately asking you for your passphrase. http://unix.stackexchange.com/questions/170750/is-there-a-way-to-specify-the-list-of-private-keys-to-add-to-ssh-agent Maybe someone has a solution for that one. – Alexis Wilke Dec 01 '14 at 00:03SSH_ASKPASS
. It turns out the embedded system usedkeyboard-interactive
authentication andSSH_ASKPASS
only works forpassword
. Since the prompt displayed usingkeyboard-interactive
looked exactly like the one whichpassword
would have used, it took me a long time before I realized whySSH_ASKPASS
never worked for me. – kasperd Jun 09 '15 at 22:12setsid(2)
while it should point tosetsid(1)
– Weijun Zhou Dec 28 '17 at 19:41ssh
session withControlMaster
ssh_config
feature enabled:setsid ssh -Nf ... host
, and then to interactively connect to the host, use:ssh ... host
which will re-use the already authenticatedssh
session. – abbe May 14 '18 at 13:17