[CentOS] Source keychain credentials in Perl?

Wed Mar 5 17:16:07 UTC 2008
Sean Carolan <scarolan at gmail.com>

>  One solution would be to "source ~/.keychain/hostname-sh" in the shell
>  before calling the perl script. That should work.

Ok, can't do this because end-users will not like the extra step.

>  Another one would be to source it before calling scp:
>
>  system ("source ~/.keychain/hostname-sh; /usr/bin/scp /tmp/filename
>  server1:/tmp/filename");

Yep, this is what I did.  I have the source ~/.keychain/hostname-sh in
every command now.  This seems the simplest solution for the time
being.

>  The third one (if you don't use a shell to invoke the perl and you
>  don't want to change every "system" call) would be to parse the file
>  inside perl and to modify the %ENV variable to include these two
>  variables. What you want is the equivalent of:
>
>  $ENV{SSH_AUTH_SOCK} = "/tmp/ssh-XXn47DUn/agent.16721";
>  $ENV{SSH_AGENT_PID} = "16722";
>
>  But of course you'd have to parse the file to get the real values.
>  Anyway, if you set that in the begining of your code, every "system"
>  you use will have these two variables exported as well.

Yes, and for this simple one-off script probably too much trouble to
go parsing the .keychain file.  Its easier to just source it before
each bash command.

Thanks for all your help, Filipe.