我有一个脚本,它使用此代码从服务器获取文件以打开会话。
sftp -o port="port" -o IdentityFile="private_key_location" "username@remote_host"
Run Code Online (Sandbox Code Playgroud)
手动运行它会成功下载文件。
但是当我使用调度程序运行脚本时,它失败并提示
No RSA host key is known for [remote_host]:port and you have requested strict checking
Host key verification failed.
Couldn't read packet: Connection reset by peer
Run Code Online (Sandbox Code Playgroud)
private_key_location
另一个用户也可以访问我的。我读过~/.ssh/known_hosts
执行脚本的地方可能没有我在~/.ssh/known_hosts
.
如果另一个用户仍然可以访问我的private_key_location
.
谢谢。
小智 6
您可以做的第一件事是在sftp
选项StrictHostKeyChecking
设置为“no”的情况下运行。
sftp -o StrictHostKeyChecking=no -o port="port" -o IdentityFile="private_key_location" "username@remote_host"
Run Code Online (Sandbox Code Playgroud)
此选项将禁用远程主机密钥检查。
否则,您可以创建全局known_hosts
文件。请参阅此答案以了解如何操作。