[root@jump121 ~]# ansible pssh -m command -a 'uptime'
192.168.80.121 | FAILED | rc=-1 >>
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.
192.168.80.114 | FAILED | rc=-1 >>
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.
192.168.80.111 | FAILED | rc=-1 >>
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.
192.168.80.116 | CHANGED | rc=0 >>
10:34:46 up 2:20, 3 users, load average: 0.00, 0.00, 0.00
[root@jump121 ~]# ansible all -m ping
\192.168.80.111 | 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."
}
192.168.80.121 | 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."
}
192.168.80.114 | 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."
}
^H192.168.80.116 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
解决方法:
使用ansible之前要做密钥认证
[root@jump121 ~]# ssh root@192.168.80.111
The authenticity of host '192.168.80.111 (192.168.80.111)' can't be established.
ED25519 key fingerprint is SHA256:InW2EeyfSJq7zUz+oYR9GtIZJz+tAsGr2U28uYylapo.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.80.111' (ED25519) to the list of known hosts.
root@192.168.80.111's password:
Last login: Thu Mar 28 10:57:29 2024 from 192.168.80.88
[root@jump111 ~]#
注销
Connection to 192.168.80.111 closed.
[root@jump121 ~]# ssh root@192.168.80.114
The authenticity of host '192.168.80.114 (192.168.80.114)' can't be established.
ED25519 key fingerprint is SHA256:FqMSYQgufsI/RkpAPv+S4X3Y3rdWdqCYYwW4mOfn99M.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.80.114' (ED25519) to the list of known hosts.
root@192.168.80.114's password:
Last login: Thu Mar 28 10:55:45 2024 from 192.168.80.88
[root@jump114 ~]#
注销
Connection to 192.168.80.114 closed.
[root@jump121 ~]# ansible all -m ping