in reply to passphrase on a RSA key with net::ssh::perl

As a workaround you could try to make a copy of the ssh key and change its password using ssh-keygen -p -f keyfilename.

This is often what you want anyway, since the whole point of passphrase protected ssh keys is that if someone gets hold of your keyfile (such as if your notebook is stolen), they can't use it. This advantage is negated if you store the password on the same computer and supply it automatically from a script. That, of course, may not be what you want: maybe you want to query the password using some GUI, I can't tell.

Update: for both the original question (supplying the passphrase to ssh) and for changing the passphrase of the key programmatically, you could try setting the SSH_ASKPASS environment variable, as documented in the manual page ssh(1).

Replies are listed 'Best First'.
Re^2: passphrase on a RSA key with net::ssh::perl
by manb (Novice) on Feb 06, 2011 at 13:44 UTC
    Hello Ambrus, Thanks for the response. When I do this outside of perl I would do it with SSH_ASKPASS. (i.e. open up ssh-agent and then ssh-add the key - and using SSH_ASKPASS as a simple shell script to provide the password to ssh-add. This automates the whole process and then lets you freely ssh with password protected keys. To tell the truth I havent tested if SSH_ASKPASS is invoked from net::ssh::perl. i.e. say when the script Khen provided up runs. If it is, then this may work as I could set it to a shell script to simply echo the password. Ill have to give it a try :)
      Try using Net::OpenSSH instead of Net::SSH::Perl. As it uses the OpenSSH client to connect to the remote machine, it would also behave in the same way, talking to ssh-agent or asking for the key passphrase on the console or through the X server (via ssh-add).

      What it does not support yet is feeding the passphrase directly from the script to the SSH client.