ansible系列4-关闭ssh首次连接时提示

在ansible配置文件中找到 /etc/ansible/ansible.cfg

方法1

在配置文件中找到

了解到问题原因为,我们了解到进行ssh连接时,可以使用-o参数将StrictHostKeyChecking设置为no,使用ssh连接时避免首次连接时让输入yes/no部分的提示。通过查看ansible.cfg配置文件,发现如下行:

[ssh_connection]
# ssh arguments to use
# Leaving off ControlPersist will result in poor performance, so use
# paramiko on older platforms rather than removing it
#ssh_args = -o ControlMaster=auto -o ControlPersist=60s

修改配置文件:

ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no 

方法2

在配置文件中找到

# uncomment this to disable SSH key host checking
host_key_checking = False 

默认host_key_checking部分是注释的,通过找开该行的注释,同样也可以实现跳过 ssh 首次连接提示验证部分。由于配置文件中直接有该选项,所以推荐用方法2 

原文地址:https://www.cnblogs.com/kuku0223/p/8669889.html