当前位置:   article > 正文

使用ansible的连通性检查的关键参数

使用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"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

可以通过修改配置文件
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"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

将host_key_checking设置为False表示禁用主机密钥检查。这可能会导致安全问题,因为这样会允许连接到未经验证的主机。建议仅在测试环境中使用此设置,并在生产环境中启用主机密钥检查以确保安全性。

如果不是将此参数打开,则必须进行ssh 过后,才能通过ansible进行连接。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/474937
推荐阅读
  

闽ICP备14008679号