SSH_ASKPASS

The ssh-add utility (see SSH agent for details) accepts a program in the environment variable SSH_ASKPASS that retrieves a passphrase from the user. This is especially useful to use the SSH agent from a script or a GUI (i.e. without a console).

$ ssh-agent bash --login
$ export SSH_ASKPASS="$(which x11-ssh-askpass)"
$ ssh-keygen -t dsa -f TEST
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in TEST.
Your public key has been saved in TEST.pub.
The key fingerprint is:
2f:ee:ad:50:27:9d:a0:33:76:00:b4:9f:64:43:a5:41 USER@HOST
$ ssh-add TEST </dev/null
# x11-ask-pass opens
Identity added: TEST (TEST)
$ _
Feedback is always welcome! If you'd like to get in touch with me concerning the contents of this article, please use Twitter.