linux - 无法通过 Ansible ping 我的远程计算机

标签 linux ansible

我正在尝试使用以下命令ping我的远程Linux计算机:

ansible remote -m ping -vvvv

我收到以下回复:

[root@ansible ansible]# ansible remote -m ping -vvvv
Using /etc/ansible/ansible.cfg as config file
Loaded callback minimal of type stdout, v2.0
<192.41.50.9> ESTABLISH SSH CONNECTION FOR USER: root
<192.41.50.9> SSH: EXEC sshpass -d12 ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o User=root -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 192.41.50.9 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1480431200.39-212981181831507 `" && echo ansible-tmp-1480431200.39-212981181831507="` echo $HOME/.ansible/tmp/ansible-tmp-1480431200.39-212981181831507 `" ) && sleep 0'"'"''
192.41.50.9 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh.",
"unreachable": true
}

我的主机文件如下所示:

[remote]
192.41.50.9

[remote:vars]
ansible_ssh_user=root
ansible_ssh_pass=p@ssw0rd
ansible_ssh_port=22

当我尝试 ssh 进入我的远程计算机时,这就是我得到的:

[root@ansible ansible]# ssh root@192.41.50.9
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
86:d2:ca:8e:aa:8a:ce:25:c7:e5:31:7e:2a:c0:11:7f.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending RSA key in /root/.ssh/known_hosts:3
RSA host key for 192.41.50.9 has changed and you have requested strict checking.
Host key verification failed.

导致连接失败的原因可能是什么?

最佳答案

如果你阅读 shell ssh 的输出,你会发现

  1. 您正在遭受中间人攻击(可能性很小)
  2. 服务器上的 ssh key 已更改(因为您重新创建了它并保留了相同的 IP)。

如果您的情况是后一种情况,您可以在 ansible 配置文件中添加以下部分 ansible.cfg

[defaults]
host_key_checking=False

关于linux - 无法通过 Ansible ping 我的远程计算机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40866213/

相关文章:

python - 改变了 Django 模型。我为 DateField 提供了一次性的 default = datetime.date。发现无效。去掉了字段还是不能迁移

arrays - 使用awk加入文件操作

postgresql - 服务器是否在本地运行并接受 Unix 域套接字 "/var/run/postgresql/.s.PGSQL.5432"上的连接

validation - 使用 ansible 的期望变量进行验证

Ansible Jinja2 字符串比较

linux - 在 html/php 输出中显示/var/log/messages?

linux - 如何在 linux 中使用 perl 从显示的输出中提取数字

c - 使用 dup2 和 execv 在 C 中获取文件夹内容

Ansible group_vars 环境变量替换

Ansible vault - 最佳实践文件夹结构