Personally I use ssh-agent. You basically type in the passphrase once when you start it up and add keys. Then you make sure your script has the ssh-agent specific environment variables set. You can do this by storing the output of ssh-agent when you first start it up in a file and then reference it when you run a script. This works flawlessly with cron.

It's a little bit of a security trade-off because anyone who can become the user who is running ssh-agent (like root) on that host can use your keys to access other machines. But, they can't copy your keys to another machine and use them because they still have a passphrase set on them. Can someone grab a snapshot of the memory space of your ssh-agent process and extract your unencrypted key? Probably, but it's not trivial.

As with all methods of authentication, there is some ultimate level of trust required.

Also, I have no idea if ssh-agent works with the all-perl implementation Net::SSH::Perl. Although I faintly remember testing this and succeeding, but it was a long time ago and I've long since lost the code. Should work okay with Net::SSH as it is a wrapper around the ssh binaries who will automatically pick up on the existence of the ssh-agent process.


In reply to Re: SSH and passphrase by pzbagel
in thread SSH and passphrase by thelma1944

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.