ansible执行playbook报Host Key checking

报错信息:

复制代码
(fastapi-ansible) root@WEB:/data/fastapi-ansible/project# ansible-playbook -i hosts ping.yaml

PLAY [Ping Test Playbook] *********************************************************************************************************************

TASK [Ping 检测] ******************************************************************************************************************************
fatal: [10.11.16.8]: 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."}

PLAY RECAP ************************************************************************************************************************************
10.11.16.8             : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
复制代码

解决办法:

方式1、在hosts文件中用ssh秘钥

[user]
10.11.16.8 ansible_ssh_user=root ansible_ssh_port=32069 ansible_ssh_private_key_file=/root/.ssh/id_rsa

方式2、修改ansible配置文件,禁用ssh秘钥主机检查

vim /etc/ansible/ansible.cfg

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

 

posted @   潇湘神剑  阅读(16)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示