【问题标题】:Perl: Permission Denied with scp_put of Net::OpenSSHPerl:使用 Net::OpenSSH 的 scp_put 拒绝权限
【发布时间】:2016-08-21 16:48:09
【问题描述】:

我正在尝试使用Net::OpenSSHscp_put 函数将文件SCP 到远程机器中。每次运行时,我都会收到以下错误:

scp failed: scp failed: child exited with code 1 at copy_certs.pl line 32.

这是我尝试此操作的代码 sn-p:

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;

当我手动执行此操作时,我没有任何权限问题。我哪里错了?

【问题讨论】:

  • 启用调试$Net::OpenSSH::debug=-1 并在此处附加输出。它将向我们展示模块在后台运行的命令。

标签: perl ssh scp openssh


【解决方案1】:

如果远程主机密钥已更改,则会出现权限问题。通过运行以下命令删除远程机器的 RSA 密钥 - "ssh-keygen -f "/.ssh/known_hosts" -R " 再试一次。

【讨论】:

  • 试过了,不是问题。
猜你喜欢
  • 2013-08-31
  • 2019-03-25
  • 2023-04-03
  • 1970-01-01
  • 2012-01-11
  • 2013-09-24
  • 2015-04-03
  • 2020-08-09
  • 1970-01-01
相关资源
最近更新 更多