CPAN::Forum
Net-SSH-Perl - How to provide a passphrase in non-interactive mode?
| Posted on Tue May 23 23:18:06 2006 by cmv |
| How to provide a passphrase in non-interactive mode? |
|
Folks- I've used this scenario to great success: 1.) Create DSA public and private keys 2.) Put public key into authorized_keys file on target machine 3.) Run cmds from this machine onto target machine without providing a password, following this template:
$ssh = Net::SSH::Perl->new($target, interactive=>0);
$ssh->login($user, ''); # Note null password
my ($stdout, $stderr, $exit) = ssh->cmd('date');
Now, I want the private key to be encrypted. This is easy to do: $key->write_private($keyfile, $passphrase); However, running the template will fail because the current Net::Perl::SSH code is designed to only get the passphrase via interaction with the user, and when interactive=>0
interaction with the user is prevented, and authentication fails. So, if I have an encrypted private key, and wish to supply the passphrase without prompting the user (please avoid going into the security holes behind this design, they've been taken care of) how can I supply the passphrase? Unless I'm missing something, this cannot be done without a code change. Off the top of my head, I'd suggest:
$ssh->login($user, $password, $passphrase);
Any help is appreciated! -Craig |
| Direct Responses: 4006 | Write a response |
(9)
]