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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |