This question already has an answer here:
I want to force ssh to always use the program specified by
SSH_ASKPASS. In my case the program is just a bash script returning the passphrase.
The problem is, as the ssh documentation says:
If ssh needs a passphrase, it will read the passphrase from the current terminal if it was run from a terminal.
So if I run ssh from a terminal,
SSH_ASKPASS is ignored.
There is a similar question: Tell SSH to use a graphical prompt for key passphrase
which proposes create an alias for ssh, like this
$ alias ssh="setsid ssh"
but doesn't work for me, because I don't call ssh directly, is called from git or rsync.
I also found an open issue in the OpenSSH Bugzilla asking for a fix, but was opened in 2002, so I don't believe is going to be implemented.
I'm thinking on probably weird solutions:
- Make a fake ssh agent, which calls the script and returns the passphrase.
- Create a process looking for new ssh processes and detach them from the terminal before ssh asks for the password.
Any better sugestion?