ansible执行命令报错Using a SSH password instead of a key is not possible because Host Key checkingis enabl | 您所在的位置:网站首页 › 连锁的餐饮店名字大全 › ansible执行命令报错Using a SSH password instead of a key is not possible because Host Key checkingis enabl |
ansible执行命令报错
192.168.100.10 | FAILED | rc=-1 >> Using a SSH password instead of a key is not possible because Host Key checkingis 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配置文件 hosts配置如下: vi /etc/ansible/hosts [local] 127.0.0.1 [test1] 192.168.100.11 ansible_ssh_user=root ansible_ssh_pass=123456 [test2] 192.168.100.12 ansible_ssh_user=root ansible_ssh_pass=123456 [test3] 192.168.100.10 ansible_ssh_user=root ansible_ssh_pass=123456 [test4] 192.168.100.9 ansible_ssh_user=root "/etc/ansible/hosts" 53L, 1301C 解决方法两种: 第一种:在本地先SSH登录一下对方设备,下次ansible 就可以正常操作了,但是比较麻烦 [root@shanan ~]# ssh [email protected] The authenticity of host '192.168.100.11 (192.168.100.11)' can't be established. ECDSA key fingerprint is SHA256:z+83zi+ptU8EEYf7ccqK5tDPDLa8ekQe+pKQ+UKX72Y. ECDSA key fingerprint is MD5:a9:be:c0:fa:44:1b:e6:84:83:78:55:2b:9f:88:c7:d6. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.100.11' (ECDSA) to the list of known hosts. [email protected]'s password: Last login: Sat Dec 26 19:39:43 2020 from 192.168.100.1 第二种:设置参数为不检查key vi /etc/ansible/ansible.cfg 在文件中进行搜索定位到 :/host_key_checking # uncomment this to disable SSH key host checking #host_key_checking = False 修改后: # uncomment this to disable SSH key host checking host_key_checking = False保存退出,重新执行命令测试: 解决!!! [root@shanan ~]# ansible test3 -a 'ls' 192.168.100.10 | CHANGED | rc=0 >> anaconda-ks.cfg original-ks.cfg 下载 公共 图片 文档 桌面 模板 视频 音乐 |
CopyRight 2018-2019 实验室设备网 版权所有 |