ansible连接时出现: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.
背景:第一次连接ansible的host里的一堆机器时,会出标题里面的错,解决办法如下:
vi /home/xiangdong/ansible/ansible.cfg
# uncomment this to disable SSH key host checking
host_key_checking = False
—————————————————————————————————————————
提示输入yes 进行确认为将key字符串加入到 ~/.ssh/known_hosts 文件中:
本篇就结合一个示例对其进行下了解。我在对之前未连接的主机进行连结时报错如下:
[root@361way.com ~]# ansible test -a 'uptime'
10.212.52.14 | FAILED => 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.212.52.16 | FAILED => 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.
从上面的输出提示上基本可以了解到由于在本机的~/.ssh/known_hosts文件中并有fingerprint key串,ssh第一次连接的时候一般会提示输入yes 进行确认为将key字符串加入到 ~/.ssh/known_hosts 文件中。
方法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 部分,使用下面的配置,避免上面出现的错误:
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no
方法2:
在ansible.cfg配置文件中,也会找到如下部分:
# uncomment this to disable SSH key host checking
host_key_checking = False
默认host_key_checking部分是注释的,通过找开该行的注释,同样也可以实现跳过 ssh 首次连接提示验证部分。由于配置文件中直接有该选项,所以推荐用方法2 。
来自:http://www.361way.com/ansible-cfg/4401.html
vi /home/xiangdong/ansible/ansible.cfg
# uncomment this to disable SSH key host checking
host_key_checking = False
—————————————————————————————————————————
提示输入yes 进行确认为将key字符串加入到 ~/.ssh/known_hosts 文件中:
本篇就结合一个示例对其进行下了解。我在对之前未连接的主机进行连结时报错如下:
[root@361way.com ~]# ansible test -a 'uptime'
10.212.52.14 | FAILED => 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.212.52.16 | FAILED => 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.
从上面的输出提示上基本可以了解到由于在本机的~/.ssh/known_hosts文件中并有fingerprint key串,ssh第一次连接的时候一般会提示输入yes 进行确认为将key字符串加入到 ~/.ssh/known_hosts 文件中。
方法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 部分,使用下面的配置,避免上面出现的错误:
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no
方法2:
在ansible.cfg配置文件中,也会找到如下部分:
# uncomment this to disable SSH key host checking
host_key_checking = False
默认host_key_checking部分是注释的,通过找开该行的注释,同样也可以实现跳过 ssh 首次连接提示验证部分。由于配置文件中直接有该选项,所以推荐用方法2 。
来自:http://www.361way.com/ansible-cfg/4401.html
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/8973/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2016-9-23 11:51
评论列表