Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有以下行的脚本
sshpass -p 'password' ssh user@server "touch /tmp/test"
这有效,当我运行脚本时,但如果我将脚本放在 cron 中它不起作用。有任何想法吗 ?
由于这是 google 上的第一个答案,因此请提供 sshpass 绝对路径,例如/usr/bin/sshpass. 你可以通过which sshpass. 我还补充说/usr/bin/ssh确定。
/usr/bin/sshpass
which sshpass
/usr/bin/ssh
添加 -o StrictHostKeyChecking=no 后它起作用了
sshpass -p 'password' ssh -o StrictHostKeyChecking=no user@server "touch /tmp/test"