本文主要是介绍使用ansible的连通性检查的关键参数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用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进行连接。
这篇关于使用ansible的连通性检查的关键参数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!