使用ansible进行ping命令的时候发现有些不通
ansible cba -m ping
10.1.1.1 | FAILED! => {
"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."
}
10.1.1.2 | FAILED! => {
"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."
}
10.1.1.3 | FAILED! => {
"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."
}
10.1.1.4 | SUCCESS => {
"changed": false,
"ping": "pong"
}
可以通过修改配置文件
vim /etc/ansible/ansible.cfg
host_key_checking = False # 检查对应服务器的host_key,建议取消注释
将注释关掉即可
[root@sc-paas-bs-teledb-66 ansible]# ansible cba -m ping
10.1.1.1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
10.1.1.2 | SUCCESS => {
"changed": false,
"ping": "pong"
}
10.1.1.3 | SUCCESS => {
"changed": false,
"ping": "pong"
}
10.1.1.4 | SUCCESS => {
"changed": false,
"ping": "pong"
}
将host_key_checking设置为False表示禁用主机密钥检查。这可能会导致安全问题,因为这样会允许连接到未经验证的主机。建议仅在测试环境中使用此设置,并在生产环境中启用主机密钥检查以确保安全性。
如果不是将此参数打开,则必须进行ssh 过后,才能通过ansible进行连接。