[CentOS] Source keychain credentials in Perl?

Wed Mar 5 17:01:42 UTC 2008
Filipe Brandenburger <filbranden at gmail.com>

On Wed, Mar 5, 2008 at 11:15 AM, Sean Carolan <scarolan at gmail.com> wrote:
>  Just so it is clear what I am trying to do, there are some scp and ssh
>  commands like:
>
>  system ("/usr/bin/scp /tmp/filename server1:/tmp/filename");
>
>  we want the scp command to use the running ssh-agent's credentials to
>  log onto the remote server.

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

Another one would be to source it before calling scp:

system ("source ~/.keychain/hostname-sh; /usr/bin/scp /tmp/filename
server1:/tmp/filename");

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.

Does this answer your question?

Filipe