ansible - error - Using a SSH password instead of a key is not possible

参考并感谢
ansible 配置面密登陆

ansible asb -m authorized_key -a "user=wfq key='{{ lookup('file','/home/wfq/.ssh/id_rsa.pub') }}'" -k

-k是指命令行直接输入密码;

报错,如下

192.168.174.132 | 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 文件中

基于这个原因,可以修改/etc/ansible/ansible.cfg配置文件

# uncomment this to disable SSH key host checking
host_key_checking = False

默认host_key_checking部分是注释的,打开该行的注释,可以实现跳过 ssh 首次连接提示验证部分。

猜你喜欢

转载自blog.csdn.net/wang725/article/details/80874646