gpt4 book ai didi

ssh - Ansible 无法与 SSH 连接(横幅交换)

转载 作者:行者123 更新时间:2023-12-04 21:30:09 24 4
gpt4 key购买 nike

如果问题不清楚和/或如果我没有问我应该在哪里,请提前抱歉。
我在通过 SSH 连接到带有 ansible 的主机时遇到问题。几天前它起作用了,但几天来我一直有相同的消息错误:

        camille@ubuntu:~$ ansible all  -m ping -u remote
192.xxx.xxx.xxx | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Connection timed out during banner exchange\r\n",
"unreachable": true
}
SSH 连接(没有ansible)运行良好,所以我不太明白这个问题。我在 Ubuntu 16.04 VM 上运行 Ansible,我想访问的主机是 CentOS 7 VM。
我的主机文件如下:
[test]    
192.xxx.xxx.xxx ansible_ssh_user=remote ansible_ssh_pass=password ansible_sudo_pass='password' #VM CentOS
我尝试了解释的解决方案 here但它没有解决问题。
编辑 1:在尝试了 Ripper Tops 解决方案并测试了其他一些东西后,我的库存现在看起来像这样:
[test]
192.xxx.xxx.xxx ansible_connection=ssh ansible_user=remote ansible_password='password'

[test:vars]
proxy=my_proxy:8080
我也尝试将超时增加到 25,但我仍然遇到同样的问题。
编辑 2 :
更改我的 ansible.cfg 文件后,错误消息已更改:
192.xxx.xxx.xxx | UNREACHABLE! => {
"changed": false,
"msg": "SSH Error: data could not be sent to remote host \"192.xxx.xxx.xxx\". Make sure this host can be reached over ssh",
"unreachable": true }
我再次测试 ssh 连接,它仍然运行良好。
我的配置文件现在是:
[defaults]

timeout = 25
host_key_checking = False
roles_path = roles/
gathering = smart

[ssh_connection]
ssh_args = -o
ControlMaster=auto -o
ControlPersist=600s
control_path = %(directory)s/%%h-%%r
pipelining = True
你有什么线索吗?

最佳答案

尝试使用 ansible_user相反 ansible_ssh_useransible_password相反 ansible_ssh_pass .这取决于您的 ansible版本。
您也可能需要放置 [group:vars]之后 [group]库存文件中的部分。

有一种简单的方法可以检查差异

ansible 192.168.15.29 -i your_hosts_file -m ping -e "ansible_ssh_user=remote ansible_ssh_pass=password"

或者

ansible 192.168.15.29 -i your_hosts_file -m ping -e "ansible_user=remote ansible_password=password"

关于ssh - Ansible 无法与 SSH 连接(横幅交换),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49629480/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com