Source keychain credentials in Perl

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");
Tags: , ,


Share This


 


3 Responses to Source keychain credentials in Perl

  1. 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

  2. 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.

  3. [...] 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 [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>