Ssh

從命令行自動接受 rsa 密鑰指紋

  • November 25, 2021

我已嘗試yes | ssh root@10.x.x.x嘗試接受 RSA 密鑰指紋,但仍會提示我是否確定要連接。有沒有辦法讓它自動化?

將這些添加到您的 bash 啟動文件或類似文件中:

#
#  ssh + scp without storing or prompting for keys.
#
function sshtmp
{
    ssh -o "ConnectTimeout 3" \
        -o "StrictHostKeyChecking no" \
        -o "UserKnownHostsFile /dev/null" \
             "$@"
}
function scptmp
{
    exec scp -o "ConnectTimeout 3" \
        -o "StrictHostKeyChecking no" \
        -o "UserKnownHostsFile /dev/null" \
        "$@"
}

然後使用sshtmp, 或scptmp代替sshand scp

注意如果您確實走這條路,您將不會被提醒主機密鑰已更改並且將失去安全性。

引用自:https://serverfault.com/questions/638600