我试图做一个Ansible ping ansible ansible all -m ping --ask-pass但是我得到SSH失败。 由于debugging日志是相当广泛的,我已经把下面的报价减less到了我认为问题发生的地方。 在日志之前,我可以连接到远程主机(一个无头RHEL5虚拟机),但实际执行“ping”时,会失败,出现下面的错误。
debug1: Entering interactive session. debug2: set_control_persist_exit_time: schedule exit in 60 seconds debug1: multiplexing control connection debug2: fd 4 setting O_NONBLOCK debug3: fd 5 is O_NONBLOCK debug3: fd 5 is O_NONBLOCK debug1: channel 1: new [mux-control] debug3: channel_post_mux_listener: new mux channel 1 fd 5 debug3: mux_master_read_cb: channel 1: hello sent debug2: set_control_persist_exit_time: cancel scheduled exit debug3: mux_master_read_cb: channel 1 packet type 0x00000001 len 4 debug2: process_mux_master_hello: channel 1 slave version 4 debug2: mux_client_hello_exchange: master version 4 debug3: mux_client_forwards: request forwardings: 0 local, 0 remote debug3: mux_client_request_session: entering debug3: mux_client_request_alive: entering debug3: mux_master_read_cb: channel 1 packet type 0x10000004 len 4 debug2: process_mux_alive_check: channel 1: alive check debug3: mux_client_request_alive: done pid = 9664 debug3: mux_master_read_cb: channel 1 packet type 0x10000002 len 264 debug2: process_mux_new_session: channel 1: request tty 1, X 0, agent 0, subsys 0, term "xterm", cmd "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1392125626.39-45498424175459 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1392125626.39-45498424175459 && echo $HOME/.ansible/tmp/ansible-tmp-1392125626.39-45498424175459'", env 0 debug3: mux_client_request_session: session request sent mm_receive_fd: no message header process_mux_new_session: failed to receive fd 0 from slave debug1: channel 1: mux_rcb failed debug2: channel 1: zombie debug2: channel 1: gc: notify user debug3: mux_master_control_cleanup_cb: entering for channel 1 debug2: channel 1: gc: user detached debug2: channel 1: zombie debug2: channel 1: garbage collecting debug1: channel 1: free: mux-control, nchannels 2 debug3: channel 1: status: The following connections are open:
我通过传统的SSH连接到主机,然后检查xterm是否在远程盒上运行,并在安装时运行。 它运行,但炸弹与以下错误:
xterm Xt error: Can't open display: xterm: DISPLAY is not set
我的直觉是,SSH连接,试图运行的命令,然后不能因为XTT炸popup来。 我一直在寻找一种方法来改变使用哪个terminal,但在文档中找不到任何东西。 任何input或build议,非常感谢。
在撰写本文时,在Windows上运行Cygwin中的Ansible有点奇怪。 不知道它是什么,但它不是我能修复的东西。 我切换到Linux虚拟机,事情已经开始正常工作。
我用了两个小时的search引擎来处理奇怪的错误,使用了以下的设置:
cat /etc/ansible/ansible.cfg [defaults] host_key_checking = False
可能对安全性不好…还有:
cat /etc/ansible/hosts [dbservers] 56.77.50.151 ansible_ssh_port=22 ansible_ssh_user=ssh_user
校验:
ansible -vvvv all -a "/bin/echo hello"
我必须确保公共的私钥validationconfiguration正确
cat id_rsa.pub >> ~/.ssh/authorized_keys cat ~/.ssh/authorized_keys chmod 0600 ~/.ssh/authorized_keys ls -al ~/.ssh/authorized_keys rm -fv ~/id_rsa.pub
我会怀疑cygwin上组和用户的configuration的转折点:和chown -v local_pc_user:local_pc_user〜/ .ssh / id_rsa.pub
最后的输出是:
<56.77.50.151> ESTABLISH CONNECTION FOR USER: ssh_user <56.77.50.151> REMOTE_MODULE command /bin/echo hello <56.77.50.151> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/local_pc_user/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic, gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=ssh_user', '-o', 'ConnectTimeout=10', '56.77.50.151', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280 && echo $HOME/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280'"] <56.77.50.151> PUT /tmp/tmprELaVU TO /export/home/ssh_user/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280/command <56.77.50.151> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/local_pc_user/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=ssh_user', '-o', 'ConnectTimeout=10' , '56.77.50.151', "/bin/sh -c '/usr/bin/python /export/home/ssh_user/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280/command; rm -rf /export/home/ssh_user/.ansible/tmp/ansible-tmp-1397676665.28-153356552524280/ >/dev/null 2>&1'"] 56.77.50.151 | success | rc=0 >> hello
这种行为在一些Ansible更新之后开始。 在较旧的Ansible版本中,我没有任何问题。 这似乎是xterm,这是问题。 为什么Ansible需要运行xterm? 我将它列为Ansible中的一个bug。
无论如何,我通过在~/.ssh/config添加以下内容来解决Cygwin中的问题:
ForwardX11是的