Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: SFTP connection failure with Perl “Net::SFTP” module

by thanos1983 (Parson)
on May 06, 2019 at 08:16 UTC ( #1233380=note: print w/replies, xml ) Need Help??


in reply to SFTP connection failure with Perl “Net::SFTP” module

Hello Michaels,

I would suggest to comment out the identity_files and also password. Simply do this:

#!/usr/bin/perl use strict; use warnings; use Net::SFTP; my $host = '127.0.0.1'; my %args = ( user => 'user', ssh_args => [ port => "10022" ] ); my $sftp = Net::SFTP->new($host, %args); my $ls = $sftp->ls('/sample/path'); print "$_->{filename}\n" for (@$ls);

I would also suggest to use the module Net::SFTP::Foreign. You can find more information as to why on a previoudly asked question Re: Using Net::SFTP.

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: SFTP connection failure with Perl “Net::SFTP” module
by Michaels (Novice) on May 06, 2019 at 08:34 UTC
    Thank you thanos1983! But how can I point to the private key file if I'll remove 'identity_files'? BR, Michael

      Hello Michaels,

      If you do not use default path of you SSH keys then you can use the option identity_files but you need to remove the password.

      Let me know if it works for you.

      BR / Thanos

      Seeking for Perl wisdom...on the process of learning...not there...yet!
        Hi thanos, I removed the password as you suggested but it still trying to login with password before using the private key:
        my %args = ( user => "$user", port => "$port", key_path => 'path/sftp_download', ssh_args => { user => "$user", identity_files => [ 'path/sftp_download'], port => "$port", protocol=>'2,1', debug => 1, } ); my $sftp=Net::SFTP->new($server, %args) or die "could not open connect +ion to $server\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1233380]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2020-05-25 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (143 votes). Check out past polls.

    Notices?