开发者

Perl Net::SFTP::Foreign Plink connection issue

开发者 https://www.devze.com 2023-03-17 07:20 出处:网络
Firstly i\'m a complete sftp & ssh newbie, and pretty new to Perl. I am trying to write a script to connect to a remote server and retrieve files. Both servers are windows 2003 boxe开发者_StackOve

Firstly i'm a complete sftp & ssh newbie, and pretty new to Perl. I am trying to write a script to connect to a remote server and retrieve files. Both servers are windows 2003 boxe开发者_StackOverflows. i have installed an sftp server on the server and can connect using the filezilla client with the same ip adress (removed from code sample for security reasons), username, and port number specified in my code.

The connection block of code i have is:

my $sftp = Net::SFTP::Foreign->new(
    host    => 'xx.xxx.xxx.xxx', 
    user    => 'radiospx', 
    port    => '22', 
    ssh_cmd => "C:\\Program Files\\putty\\plink.exe",
    more    => [qw(-v -i )]
); 

$sftp->error and die " SSH connection failed: " . $sftp->error;

When i run the script i get the following output:

Looking up host "sftp" unable to open connection: Host does not exist SSH connection failed: Connection to remote server is broken at import.pl line 34

Can anyone suggest where i'm going wrong. the server is definitely accepting sftp connections as filezilla works perfectly.


the -i plink option you are passing through more requires an argument:

my $sftp = Net::SFTP::Foreign->new(
    host    => 'xx.xxx.xxx.xxx', 
    user    => 'radiospx', 
    port    => '22', 
    ssh_cmd => "C:\\Program Files\\putty\\plink.exe",
    more    => ['-v', -i => "C:\\path\\to\\the\\private.key"]
); 

$sftp->error and die " SSH connection failed: " . $sftp->error;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号