Reputation: 1949
I'm trying to SCP a file into a remote machine using Net::OpenSSH
's scp_put
function. Every time I run, I get the following error:
scp failed: scp failed: child exited with code 1 at copy_certs.pl line 32.
This is the code snippet where I attempt this operation:
use Net::SSH::Perl;
use Exporter;
use Net::OpenSSH;
my $user = "hello";
my $pass = "hello";
my $remote_path = "/hello_folder/ssl";
$host="10.221.33.4";
my $ssh = Net::OpenSSH->new($host, user => $user, password => $pass, master_opts => [-o => "StrictHostKeyChecking=no"]);
$key_file = "certs/mykey.key";
$ssh->scp_put($key_file, $remote_path)
or die "scp failed: " . $ssh->error;
When I perform this operation manually, I don't have any permission issues. Where am I going wrong?
Upvotes: 2
Views: 908
Reputation: 3011
If the remote host key has changed, there would be permission issues. Remove the RSA key of remote machine by running the following command - "ssh-keygen -f "/.ssh/known_hosts" -R " and try again.
Upvotes: 2