I am involved in a FTP to SFTP migration and have chosen Net::SFTP::Foreign as the Perl module to use to accomplish this. I have successfully modified all Perl scripts to this effect. Now another curve ball has been thrown my way ... now SSH2 (RSA) public key authentication is required. I have created the key files and passed along the public key . I am trying to use "key_path". I have changed the code from

%args = ( "user" => $remuser, "password" => $rempswd ); $sftp = Net::SFTP::Foreign->new( $remnode,%args, stderr_discard => 1 ) +;

for testing this to

$sftp = Net::SFTP::Foreign->new( $remnode ,key_path => '/export/home/secbatch/.ssh/id_rsa' , stderr_discard => 1);

After each call to $sftp = Net::SFTP::Foreign->new there is

if ( $sftp->error ) { print "Connect Failed!"; print "\n$@"; ##if $DEBUG; print "\nConnect error: " . $sftp->error . "\n"; print "\nConnect status: " . $sftp->status . "\n";

My log files show this

Connecting to Remote System: ... Connect Failed!

Connect error: Connection to remote server is broken

Connect status: Connection lost

Here is the dir

/export/home/secbatch/.ssh>% ls -l

total 34

drwx------ 2 secbatch gsm 1024 Feb 25 14:04 .

drwxr-xr-x 75 secbatch gsm 6144 Feb 4 17:15 ..

-rw------- 1 secbatch gsm 1675 Feb 25 14:04 id_rsa

-rw-r--r-- 1 secbatch gsm 403 Feb 25 14:04 id_rsa.pub

In the META::CPAN page for Net::SFTP::Foreign there is this note ... "Note also that latest versions of Net::SFTP::Foreign support the key_path argument".

I am successful when I try from command line with sftp -v username@remote host

.

A snippet from output ...

debug1: Authentications that can continue: publickey,password,keyboard-interactive

debug1: Next authentication method: publickey

debug1: Offering RSA public key: /export/home/secbatch/.ssh/id_rsa

debug1: Server accepts key: pkalg ssh-rsa blen 279

debug1: read PEM private key done: type RSA

debug1: Authentication succeeded (publickey).

Any guidance would be greatly appreciated.

In reply to Net::SFTP::Foreign key_path by Vita

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.