当我手动运行这个 Perl 脚本时,它可以建立连接。但是当我实现到系统中时,它会显示:authenticity of the target host can't be established, the remote host public key is probably not present on the '~/.ssh/known_hosts' file
.
我需要这方面的帮助和建议。
my $host = "xxxs.com";
my $sftp = Net::SFTP::Foreign->new($host,user => 'xxx', password => 'xxx',
more => '-v',stderr_fh => $ssherr);
最佳答案
看看FAQ在 Net::SFTP::Foreign 文档中。它在 下归档主机 key 检查 并且是最后一个条目。这是一个摘录。
Host key checking
Q: Connecting to a remote server with password authentication fails with the following error:
The authenticity of the target host can not be established, connect from the command line first
A: That probably means that the public key from the remote server is not stored in the
~/.ssh/known_hosts file
. Run an SSH Connection from the command line as the same user as the script and answer yes when asked to confirm the key supplied.
那里也有一个例子。
关于Perl远程写文件连接报错Net::SFTP::Foreign,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11113889/