使用以下方式可避免第一次詢問,直接把該 host 加入
# ssh newhost -oStrictHostKeyChecking=no "command"
或是直接修改 /etc/ssh/ssh_config 把這個參數設定就不需要每次打
參考來源:http://wangmk.blog.51cto.com/651644/183939
ssh IP -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no "command"
这样的格式可以避免输入 yes ,可以再交互式脚本中使用
man 5 ssh_config
UserKnownHostsFile
Specifies a file to use for the user host key database instead of ~/.ssh/known_hosts.
StrictHostKeyChecking
If this flag is set to "yes", ssh will never automatically add host keys to the ~/.ssh/known_hosts file,
and refuses to connect to hosts whose host key has changed. This provides maximum protection against
trojan horse attacks, however, can be annoying when the /etc/ssh/ssh_known_hosts file is poorly main-
tained, or connections to new hosts are frequently made. This option forces the user to manually add all
new hosts. If this flag is set to "no", ssh will automatically add new host keys to the user known hosts
files. If this flag is set to "ask", new host keys will be added to the user known host files only after
the user has confirmed that is what they really want to do, and ssh will refuse to connect to hosts whose
host key has changed. The host keys of known hosts will be verified automatically in all cases. The
argument must be "yes", "no" or "ask". The default is "ask".
沒有留言:
張貼留言