Source keychain credentials in Perl
| 09-Jun-2009 | Posted by Sonia Hamilton under Cron, Perl, Ssh |
I use keychain for securely caching my ssh key credentials when running scripts from cron.
Here’s how to use keychain with Perl scripts:
Create a wrapper script: source ~/.keychain/hostname-sh run_perl_program.pl
To run a one-off command do:
system("source ~/.keychain/hostname-sh; cmd");
Share This
nice tip.
dont forget your soon to be new friend Net::SSH::Expect
you can apt-get it in debian, dont know about ubuntu
libnet-ssh-expect-perl
Yes I was looking at Net::SSH::Perl too (has better handling of stderr than SSH::Perl) and noticed Net::SSH::Expect. I’m on old fan of Expect, having had to script in the past nasty things like password changes on ‘n’ boxes. Perl integration is nice – not Yet Another Language (TCL) to master.
[...] before you add a comment saying use ssh keys or keychain, this is totally insecure, I agree with you! Key based authentication is disabled on the target [...]