Hello,
I have an environment where a perl script is called from inside a shell script.
The shell script starts ssh-agent and ssh-add so that environment variable SSH_AUTH_SOCK is set.
I would like to use that environment variable from inside the called perl script.
My ssh key has a passphrase set and so my goal would be to be able to talk to the ssh-agent from inside the perl script; this way I will be prompted for passphrase (not password) only once when running ssh-add in the shell script while some rdist subcommands that are inside the perl script will not ask for passhprase any more but talk directly to ssh-agent setup previously.
If I had to do this all in shell script (so a shell script that calls another shell script) I can reach this goal calling the inner shell script with something like:
env SSH_AUTH_SOCK=$SSH_AUTH_SOCK inner_script.sh
The same doesn't work ootb if the inner is a perl script.
I found on the web about Net::SSH::Perl::Agent that seems to be the thing for me but I don't understand how to use it (I'm a very beginner in perl and the perl script is not totally under my control...) to be able to inherit the env SSH_AUTH_SOCK and use it to automatically talk with the ssh- agent.
Any hints/example?
I don't know if this makes any difference, but the way my rdist commands are called inside the perl script is something like:
my $command="rdist $RDIST_OPTIONS";
open(RDIST, "$command 2>&1 |" ) ||
die("$basename: Unable to open $command\n");
my $errorcount = 0;
while ( <RDIST> ) {
... some other commands/conditional statements ...
}
So I would like the rdist command not to ask for passhprase for every host it has to process...
Thanks in advance,
Gianluca
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.