如何从 init.d 中获取 scp

How to scp from init.d

我正在尝试从 /etc/init.d 目录执行以下脚本

sshpass -p 'password' scp root@remote_IP:/file /copy/to/my/location

该脚本 运行 完全来自命令行。我得到 "Host key verification failed" 的错误。当我使用其他命令时,例如

echo "something" > /path/to/output/file.txt

脚本已经执行,所以没有问题。问题出在 scp 命令上,我想它与密钥有关。

任何人都可以就如何从 /etc/init.d/ 目录中 运行 scp 提出一些建议吗?

非常感谢提前

host key verification failed 表示您的 ssh 配置需要严格的主机密钥验证,并且远程主机的密钥与您的 known_hosts 文件中的密钥不匹配。 如果 init 脚本是 运行 作为 root,将主机密钥添加到 /root/.ssh/known_hosts 或(不太安全)关闭 /root/.ssh/config 中远程主机的主机密钥验证 有关更多讨论,请参阅 https://askubuntu.com/questions/87449/how-to-disable-strict-host-key-checking-in-ssh