ssh - Ansible给出ssh_exchange_identification错误

标签 ssh ansible

我的Ansible剧本使用代理连接到远程节点。

当Ansible剧本运行时;在执行ssh步骤时,会显示以下错误。

[root@vm1-msdp ANSIBLE]# ansible-playbook fend_file.yaml -i env/target -vvvvv

PLAY [LAB1] ******************************************************************* 

GATHERING FACTS *************************************************************** 
<10.169.99.222> ESTABLISH CONNECTION FOR USER: msdp
<10.169.99.222> REMOTE_MODULE setup
<10.169.99.222> EXEC sshpass -d9 ssh -C -tt -vvv -o ProxyCommand="nc -x 142.133.134.161:1088 %h %p" -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no -o PubkeyAuthentication=no -o User=msdp -o ConnectTimeout=10 10.169.99.222 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1473708903.98-28407509853006 && echo $HOME/.ansible/tmp/ansible-tmp-1473708903.98-28407509853006'
fatal: [10.169.99.222] => SSH Error: ssh_exchange_identification: Connection closed by remote host
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

但是当我自己运行ssh命令时,我能够成功连接。
[root@vm1-msdp ANSIBLE]# ssh -C -tt -o ProxyCommand="nc -x 142.133.134.161:1088 %h %p" -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no -o PubkeyAuthentication=no -o User=root -o ConnectTimeout=10 10.169.99.222
root@10.169.99.222's password: 
Last login: Mon Sep 12 12:28:19 2016 from 10.169.102.6
root@IC02 ~ #

我需要清除任何ansible文件吗?

最佳答案

手动运行SSH命令时,您是在指定root用户。您的Ansible剧本正在使用本地用户msdp。尝试在库存文件中设置ansible_user变量。也许像这样:
10.169.99.22 ansible_user=root

关于ssh - Ansible给出ssh_exchange_identification错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39457540/

相关文章:

git - 如何使用非 root 用户为 git 部署配置 ssh 代理服务和 key ?

github - Spring Cloud/Jgit/Github无法使用SSH

ansible - ansible local_action 没有 yaml 语法?

Ansible 变量 : Can I reference a variable within itself?

bash - 如何使用 ssh 连接到远程服务器并获取信息

c++ - 远程运行 C++ 程序;加载共享库时出错

c++ - curl 错误 - ssh 层中的 79 错误

ansible - 如果文件有模式,如何在 Ansible 中跳过模板副本?

ansible - 如何在 Ansible `find` 模块中使用通配符路径?

amazon-web-services - 使用 ec2 标签在 ansible 上创建 Metric 警报