Perl:权限被net :: OpenSSH的scp_put拒绝
问题描述:
我正在尝试使用Net::OpenSSH
的scp_put
函数将SCP文件导入远程机器。每次我跑,我得到以下错误:Perl:权限被net :: OpenSSH的scp_put拒绝
scp failed: scp failed: child exited with code 1 at copy_certs.pl line 32.
这是代码片段,我尝试这样操作:
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;
当我手动执行此操作,我没有任何权限的问题。我哪里错了?
答
如果远程主机密钥已更改,则会出现权限问题。通过运行以下命令删除远程计算机的RSA密钥 - “ssh-keygen -f”/.ssh/known_hosts“-R”,然后重试。
+2
试过了,这不是问题。 –
启用调试'$ Net :: OpenSSH :: debug = -1'并在此附上输出。它会向我们展示模块在引擎盖下运行的命令。 – salva