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

文章讲述了在使用Ansible进行ping命令时遇到的SSH密码验证失败问题,解决方法是修改`host_key_checking`设置为False,但建议在测试环境中禁用,在生产环境中启用以保证安全性。
摘要由CSDN通过智能技术生成

使用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进行连接。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值