Reputation: 33
I am using Net:SSH2 to put file on a remote server with scp_put. It returns unknown error:
-43, LIBSSH2_ERROR_UNKNOWN(-43), SCP failure
It seems that the error comes after some timeout/delay, as it takes several minutes to return.
Connection to sftp-server is working. I can get a directory list from the directory.
I have access rights to that directory as I can put files there with SFTP-client.
I am using Strawberry Perl in Windows environment.
use warnings;
use strict;
use Net::SSH2;
my $dir1 = '.';
my $file = 'D:\\test\\test.txt';
my $ssh2 = Net::SSH2->new();
$ssh2->connect('testserver') or die "Unable to connect Host $@ \n";
$ssh2->auth_password('test','test') or die "Unable to login $@ \n";
if($ssh2->scp_put($file, $dir1)) {
print "File $file transferred to $dir1\n";
} else {
print "Couldn't transfer file $file to $dir1\n";
print join ', ', $ssh2->error;
print "\n";
}
Upvotes: 2
Views: 445
Reputation: 10242
SCP support in libssh2 is quite rudimentary and buggy.
Better alternatives are Net::SSH::Any which has a proper pure-perl implementation of SCP or Net::SFTP::Foreign for SFTP. Both can work on top of Net::SSH2.
Upvotes: 1