#1 - Missing package?
You're probably missing the package that contains
ssh-askpass. Try installing it.
$ sudo yum install openssh-askpass
$ sudo apt-get install ssh-askpass-gnome ssh-askpass
Finding missing utilities
You can search for missing tools using these commands:
$ 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
$ apt-file -l search ssh-askpass
#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.
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
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.
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
So if we put this all together:
$ setsid ssh user@remotehost
$ setsid ssh user@skinner
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