# SSH connection to host failed..

**URL:** <https://forum.ansible.com/t/ssh-connection-to-host-failed/20918>\
**Category:** Ansible Project\
**Created:** [March 18, 2016, 1:26pm UTC](https://forum.ansible.com/t/ssh-connection-to-host-failed/20918 "2016-03-18T13:26:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrzej\_K](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@Andrzej\_K](https://forum.ansible.com/u/Andrzej_K)\
**Post date:** [March 18, 2016, 1:26pm UTC](https://forum.ansible.com/t/ssh-connection-to-host-failed/20918/1 "2016-03-18T13:26:59Z")

</div>

Hello Guys,

Can someone of you help me with this strange case? I have host running CentOS 6.7 x86\_64. My ansible management host is CentOS 7.2 x86\_64, ansible version 1.9.4. When I try to run playbook against my host I’m getting this message:

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [vzylvrnddev3] =\> {“failed”: true, “parsed”: false}  
/var/tmp/sclAxMdst: line 8: -k: command not found  
OpenSSH\_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 56: Applying options for \*  
debug1: auto-mux: Trying existing master  
debug1: mux\_client\_request\_session: master session id: 2  
Shared connection to vzylvrnddev3 closed.

for more info:

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
 ESTABLISH CONNECTION FOR USER: ansible  
 REMOTE\_MODULE setup  
 EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/home/ansible-admin/.ansible/cp/ansible-ssh-%h-%p-%r” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 vzylvrnddev3 /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1458307518.98-232218326920679 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1458307518.98-232218326920679 && echo $HOME/.ansible/tmp/ansible-tmp-1458307518.98-232218326920679’  
 PUT /tmp/tmpCkdV99 TO /home/ansible/.ansible/tmp/ansible-tmp-1458307518.98-232218326920679/setup  
 EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/home/ansible-admin/.ansible/cp/ansible-ssh-%h-%p-%r” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 vzylvrnddev3 /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=] password: " -u root /bin/sh -c '”’“‘echo BECOME-SUCCESS-; LANG=C LC\_CTYPE=C /usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1458307518.98-232218326920679/setup; rm -rf /home/ansible/.ansible/tmp/ansible-tmp-1458307518.98-232218326920679/ \>/dev/null 2\>&1’”‘"’’  
failed: [vzylvrnddev3] =\> {“failed”: true, “parsed”: false}  
/var/tmp/sclRLbVXV: line 8: -k: command not found  
OpenSSH\_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 56: Applying options for \*  
debug1: auto-mux: Trying existing master  
debug2: fd 3 setting O\_NONBLOCK  
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\_client\_request\_alive: done pid = 5502  
debug3: mux\_client\_request\_session: session request sent  
debug1: mux\_client\_request\_session: master session id: 2  
debug3: mux\_client\_read\_packet: read header failed: Broken pipe  
debug2: Received exit status from master 127  
Shared connection to vzylvrnddev3 closed.

Any idea why I’m getting this message? I restored /etc/ssh/sshd\_config and ssh\_config to default - it’s still the same. What is the reason?

thanks in advance!

---

<div class="post-metadata">

**Author:** ![alfred.e.kenny](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@alfred.e.kenny](https://forum.ansible.com/u/alfred.e.kenny)\
**Post date:** [May 12, 2017, 6:21pm UTC](https://forum.ansible.com/t/ssh-connection-to-host-failed/20918/2 "2017-05-12T18:21:35Z")

</div>

I have nearly the exact same issue. Have you managed to find a solution?

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [May 13, 2017, 2:51pm UTC](https://forum.ansible.com/t/ssh-connection-to-host-failed/20918/3 "2017-05-13T14:51:07Z")

</div>

ConnectTimeout=10 vzylvrnddev3 /bin/sh -c 'sudo -k && sudo -H -S -p  
"[sudo via ansible, key=] password: " -u root /bin/sh -c '"'"'echo  
BECOME-SUCCESS-; LANG=C LC\_CTYPE=C /usr/bin/python  
/home/ansible/.ansible/tmp/ansible-tmp-1458307518.98-232218326920679/setup;  
rm -rf /home/ansible/.ansible/tmp/ansible-tmp-1458307518.98-232218326920679/

> /dev/null 2\>&1'"'"''

failed: [vzylvrnddev3] =\> {"failed": true, "parsed": false}  
/var/tmp/sclRLbVXV: line 8: -k: command not found

Does the sudo on the host not understand the '-k' flag?

---

<div class="post-metadata">

**Author:** ![alfred.e.kenny](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@alfred.e.kenny](https://forum.ansible.com/u/alfred.e.kenny)\
**Post date:** [May 14, 2017, 3:21pm UTC](https://forum.ansible.com/t/ssh-connection-to-host-failed/20918/4 "2017-05-14T15:21:42Z")

</div>

As it turns out, in my case the issue was that sftp was purposefully unsupported on the remote machine. Switching to scp solved this problem.
