發如今刪掉 ~/.ssh/know_hosts 以後運行 ansible api 會出現如下提示vim
The authenticity of host '10.1.*.* (10.1.*.*)' can't be established. RSA key fingerprint is 43:54:a5:c0:f8:4a:a2:d2:1a:ef:87:8f:90:f5:dd:4a. Are you sure you want to continue connecting (yes/no)?
由於在腳本里面自動運行調用,沒法使用 pexpect 模塊,也沒法捕捉到 這段提示的輸出,ansible 源碼研究不夠透徹搞了半天也沒解決,最後只能從根本途徑上面解決問題,直接修改 ssh 配置,去掉該段提示。api
vim /etc/ssh/ssh_config Host * StrictHostKeyChecking no
重啓 sshdssh
service sshd restart