2016-04-27 75 views
2

我正在嘗試使用Net::OpenSSHscp_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; 

當我手動執行此操作,我沒有任何權限的問題。我哪裏錯了?

+1

啓用調試'$ Net :: OpenSSH :: debug = -1'並在此附上輸出。它會向我們展示模塊在引擎蓋下運行的命令。 – salva

回答

2

如果遠程主機密鑰已更改,則會出現權限問題。通過運行以下命令刪除遠程計算機的RSA密鑰 - 「ssh-keygen -f」/.ssh/known_hosts「-R」,然後重試。

+2

試過了,這不是問題。 –