# SSH connection problem

**URL:** <https://forum.ansible.com/t/ssh-connection-problem/15244>\
**Category:** Ansible Project\
**Created:** [May 15, 2014, 9:57am UTC](https://forum.ansible.com/t/ssh-connection-problem/15244 "2014-05-15T09:57:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_Kent](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@Ian\_Kent](https://forum.ansible.com/u/Ian_Kent)\
**Post date:** [May 15, 2014, 9:57am UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/1 "2014-05-15T09:57:07Z")

</div>

Hi

I’m having some issues getting ansible to connect using SSH, but it only seems to affect one particular playbook. The odd thing is I can connect manually using ssh, but ansible fails with a timed out error. Other playbooks/hosts work absolutely fine with exactly the same config.

Here’s the output I get - a lot less than I’d normally expect for a failure (no ssh debug output etc):

`  
-----@localhost:~/github/--------/ansible$ ansible-playbook -i hosts playbook.yml -vvvv

PLAY [all] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<ec2--------------.eu-west-1.compute.amazonaws.com\> ESTABLISH CONNECTION FOR USER: ec2-user on PORT 22 TO ec2--------------.eu-west-1.compute.amazonaws.com  
fatal: [ec2--------------.eu-west-1.compute.amazonaws.com] =\> {‘msg’: ‘FAILED: timed out’, ‘failed’: True}

TASK: [common | install wget] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FATAL: no hosts matched or all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/home/-------/playbook.retry

ec2--------------.eu-west-1.compute.amazonaws.com : ok=0 changed=0 unreachable=1 failed=0

`

But it works fine using ssh directly:

`  
-------@localhost:~/github/---------/ansible$ ssh ec2-user@ec2--------------.eu-west-1.compute.amazonaws.com

Last login: Thu May 15 05:15:13 2014 from —.–.–.–  
[ec2-user@ip-------------- ~]$ exit  
logout  
Connection to ec2--------------.eu-west-1.compute.amazonaws.com closed.  
`

SSH config is set to use corkscrew to proxy over http, which works fine on other playbooks/sites and from command line:

`  
KeepAlive yes  
ServerAliveInterval 60

Host \*.compute.amazonaws.com  
IdentityFile ~/.ssh/-----------.pem  
ProxyCommand /usr/bin/corkscrew -------.--------- 8080 %h %p  
StrictHostKeyChecking no  
`

Tried all the usual stuff, swapping hosts between working/failing playbooks, rebooting, etc - out of ideas!

Any suggestions?

Thanks  
Ian

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 15, 2014, 11:38am UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/2 "2014-05-15T11:38:39Z")

</div>

Please show the output from that first task as it’s trying to connect with “-vvvv” on the command line, and also the SSH debug from the other so we can see what ports it is trying to talk to there, etc.

It also doesn’t matter here I’m guessing, but it’s always useful to indicate your ansible version when asking a question.

Your host OS also matters, “-c ssh” will read your SSH config, paramiko will not.

Thanks!

---

<div class="post-metadata">

**Author:** ![Ian\_Kent](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@Ian\_Kent](https://forum.ansible.com/u/Ian_Kent)\
**Post date:** [May 15, 2014, 2:58pm UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/3 "2014-05-15T14:58:43Z")

</div>

Thanks for the reply - not too sure what you mean exactly! The output I pasted was the “broken” one running with -vvvv, and this is the output from a working ansible playbook using -vvvv (cut just before it starts running any tasks, but the connection was successful)

All using ansible 1.6. Host OS is Ubuntu 13.10. Both ansible and host OS are the same whether it works or not!

The bit that I dont get is why it works fine with other ansible playbooks, and that the debug output doesn’t even appear to be trying an actual SSH connection (no ssh debug output, just a connection timed out). Any other failure normally comes with a pile of SSH debug like the example below, just get nothing on this one.

`  
-------@----------:~/github/--------------$ ansible-playbook -i aws\_hosts site.yml -vvvv

PLAY [all] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<ec2-------------.eu-west-1.compute.amazonaws.com\> ESTABLISH CONNECTION FOR USER: ec2-user  
\<ec2-------------.eu-west-1.compute.amazonaws.com\> REMOTE\_MODULE setup  
\<ec2-------------.eu-west-1.compute.amazonaws.com\> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/home/-------/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ec2-user’, ‘-o’, ‘ConnectTimeout=10’, ‘ec2-------------.eu-west-1.compute.amazonaws.com’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1400161941.7-189110912378024 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1400161941.7-189110912378024 && echo $HOME/.ansible/tmp/ansible-tmp-1400161941.7-189110912378024’”]  
\<ec2-------------.eu-west-1.compute.amazonaws.com\> PUT /tmp/tmpe6lXpq TO /home/ec2-user/.ansible/tmp/ansible-tmp-1400161941.7-189110912378024/setup  
\<ec2-------------.eu-west-1.compute.amazonaws.com\> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/home/-------/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ec2-user’, ‘-o’, ‘ConnectTimeout=10’, ‘ec2-------------.eu-west-1.compute.amazonaws.com’, ‘/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=fvfeyzswxnomddeasiytndsflxlotzve] password: " -u root /bin/sh -c '”'“'echo SUDO-SUCCESS-fvfeyzswxnomddeasiytndsflxlotzve; /usr/bin/python /home/ec2-user/.ansible/tmp/ansible-tmp-1400161941.7-189110912378024/setup; rm -rf /home/ec2-user/.ansible/tmp/ansible-tmp-1400161941.7-189110912378024/ \>/dev/null 2\>&1'”'"''’]  
ok: [ec2--------------.eu-west-1.compute.amazonaws.com]

`

If I connect using ssh command, this is the debug output from a successful connect:

`  
-------@------------:~/github/-------------$ ssh ec2-user@ec2--------------.eu-west-1.compute.amazonaws.com -vvvv  
OpenSSH\_6.2p2 Ubuntu-6ubuntu0.4, OpenSSL 1.0.1e 11 Feb 2013  
debug1: Reading configuration data /home/-------/.ssh/config  
debug1: /home/-------/.ssh/config line 9: Applying options for _.compute.amazonaws.com  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 19: Applying options for \*  
debug2: ssh\_connect: needpriv 0  
debug1: Executing proxy command: exec /usr/bin/corkscrew -------.--------.-- 8080 ec2--------------.eu-west-1.compute.amazonaws.com 22  
debug1: permanently\_drop\_suid: 1000  
debug3: Incorrect RSA1 identifier  
debug3: Could not load “/home/-------/.ssh/-----------.pem” as a RSA1 public key  
debug1: identity file /home/-------/.ssh/-----------.pem type -1  
debug1: identity file /home/-------/.ssh/-----------.pem-cert type -1  
debug1: Enabling compatibility mode for protocol 2.0  
debug1: Local version string SSH-2.0-OpenSSH\_6.2p2 Ubuntu-6ubuntu0.4  
debug1: Remote protocol version 2.0, remote software version OpenSSH\_5.3  
debug1: match: OpenSSH\_5.3 pat OpenSSH\_5_  
debug2: fd 5 setting O\_NONBLOCK  
debug2: fd 4 setting O\_NONBLOCK  
debug3: load\_hostkeys: loading entries for host “ec2--------------.eu-west-1.compute.amazonaws.com” from file “/home/-------/.ssh/known\_hosts”  
debug3: load\_hostkeys: found key type RSA in file /home/-------/.ssh/known\_hosts:74  
debug3: load\_hostkeys: loaded 1 keys  
debug3: order\_hostkeyalgs: prefer hostkeyalgs: [ssh-rsa-cert-v01@openssh.com](mailto:ssh-rsa-cert-v01@openssh.com),ssh-rsa-cert-v00@openssh.com,ssh-rsa  
debug1: SSH2\_MSG\_KEXINIT sent  
debug1: SSH2\_MSG\_KEXINIT received  
debug2: kex\_parse\_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1  
debug2: kex\_parse\_kexinit: [ssh-rsa-cert-v01@openssh.com](mailto:ssh-rsa-cert-v01@openssh.com),ssh-rsa-cert-v00@openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss  
debug2: kex\_parse\_kexinit: [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com](mailto:aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com),aes256-gcm@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se  
debug2: kex\_parse\_kexinit: [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com](mailto:aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com),aes256-gcm@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se  
debug2: kex\_parse\_kexinit: [hmac-md5-etm@openssh.com](mailto:hmac-md5-etm@openssh.com),hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96  
debug2: kex\_parse\_kexinit: [hmac-md5-etm@openssh.com](mailto:hmac-md5-etm@openssh.com),hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96  
debug2: kex\_parse\_kexinit: [none,zlib@openssh.com](mailto:none,zlib@openssh.com),zlib  
debug2: kex\_parse\_kexinit: [none,zlib@openssh.com](mailto:none,zlib@openssh.com),zlib  
debug2: kex\_parse\_kexinit:  
debug2: kex\_parse\_kexinit:  
debug2: kex\_parse\_kexinit: first\_kex\_follows 0  
debug2: kex\_parse\_kexinit: reserved 0  
debug2: kex\_parse\_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1  
debug2: kex\_parse\_kexinit: ssh-rsa,ssh-dss  
debug2: kex\_parse\_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se  
debug2: kex\_parse\_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se  
debug2: kex\_parse\_kexinit: [hmac-md5,hmac-sha1,umac-64@openssh.com](mailto:hmac-md5,hmac-sha1,umac-64@openssh.com),hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96  
debug2: kex\_parse\_kexinit: [hmac-md5,hmac-sha1,umac-64@openssh.com](mailto:hmac-md5,hmac-sha1,umac-64@openssh.com),hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96  
debug2: kex\_parse\_kexinit: [none,zlib@openssh.com](mailto:none,zlib@openssh.com)  
debug2: kex\_parse\_kexinit: [none,zlib@openssh.com](mailto:none,zlib@openssh.com)  
debug2: kex\_parse\_kexinit:  
debug2: kex\_parse\_kexinit:  
debug2: kex\_parse\_kexinit: first\_kex\_follows 0  
debug2: kex\_parse\_kexinit: reserved 0  
debug2: mac\_setup: found hmac-md5  
debug1: kex: server-\>client aes128-ctr hmac-md5 none  
debug2: mac\_setup: found hmac-md5  
debug1: kex: client-\>server aes128-ctr hmac-md5 none  
debug1: SSH2\_MSG\_KEX\_DH\_GEX\_REQUEST(1024\<1024\<8192) sent  
debug1: expecting SSH2\_MSG\_KEX\_DH\_GEX\_GROUP  
debug2: dh\_gen\_key: priv key bits set: 126/256  
debug2: bits set: 502/1024  
debug1: SSH2\_MSG\_KEX\_DH\_GEX\_INIT sent  
debug1: expecting SSH2\_MSG\_KEX\_DH\_GEX\_REPLY  
debug1: Server host key: RSA ab:80:6d:67:d9:32:35:9e:cf:8c:e3:40:bf:3f:f4:a7  
debug3: load\_hostkeys: loading entries for host “ec2--------------.eu-west-1.compute.amazonaws.com” from file “/home/-------/.ssh/known\_hosts”  
debug3: load\_hostkeys: found key type RSA in file /home/-------/.ssh/known\_hosts:74  
debug3: load\_hostkeys: loaded 1 keys  
debug1: Host ‘ec2---------------.eu-west-1.compute.amazonaws.com’ is known and matches the RSA host key.  
debug1: Found key in /home/-------/.ssh/known\_hosts:74  
debug2: bits set: 504/1024  
debug1: ssh\_rsa\_verify: signature correct  
debug2: kex\_derive\_keys  
debug2: set\_newkeys: mode 1  
debug1: SSH2\_MSG\_NEWKEYS sent  
debug1: expecting SSH2\_MSG\_NEWKEYS  
debug2: set\_newkeys: mode 0  
debug1: SSH2\_MSG\_NEWKEYS received  
debug1: Roaming not allowed by server  
debug1: SSH2\_MSG\_SERVICE\_REQUEST sent  
debug2: service\_accept: ssh-userauth  
debug1: SSH2\_MSG\_SERVICE\_ACCEPT received  
debug2: key: ------@--------- (0x------------),  
debug2: key: -------@---------------- (0x-------------),  
debug2: key: /home/--------/.ssh/------------.pem ((nil)), explicit  
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic  
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic  
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password  
debug3: authmethod\_lookup gssapi-keyex  
debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password  
debug3: authmethod\_is\_enabled gssapi-keyex  
debug1: Next authentication method: gssapi-keyex  
debug1: No valid Key exchange context  
debug2: we did not send a packet, disable method  
debug3: authmethod\_lookup gssapi-with-mic  
debug3: remaining preferred: publickey,keyboard-interactive,password  
debug3: authmethod\_is\_enabled gssapi-with-mic  
debug1: Next authentication method: gssapi-with-mic  
debug1: Unspecified GSS failure. Minor code may provide more information  
Credentials cache file ‘/tmp/krb5cc\_1000’ not found

debug1: Unspecified GSS failure. Minor code may provide more information  
Credentials cache file ‘/tmp/krb5cc\_1000’ not found

debug1: Unspecified GSS failure. Minor code may provide more information

debug1: Unspecified GSS failure. Minor code may provide more information  
Credentials cache file ‘/tmp/krb5cc\_1000’ not found

debug2: we did not send a packet, disable method  
debug3: authmethod\_lookup publickey  
debug3: remaining preferred: keyboard-interactive,password  
debug3: authmethod\_is\_enabled publickey  
debug1: Next authentication method: publickey  
debug1: Offering RSA public key: -----@---------  
debug3: send\_pubkey\_test  
debug2: we sent a publickey packet, wait for reply  
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic  
debug1: Offering RSA public key: -------@----------------  
debug3: send\_pubkey\_test  
debug2: we sent a publickey packet, wait for reply  
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic  
debug1: Trying private key: /home/--------/.ssh/------------.pem  
debug1: read PEM private key done: type RSA  
debug3: sign\_and\_send\_pubkey: RSA e5:df:37:7f:6b:1a:69:0e:01:89:ea:5e:6e:77:2a:28  
debug2: we sent a publickey packet, wait for reply  
debug1: Authentication succeeded (publickey).  
Authenticated to ec2-------------------.eu-west-1.compute.amazonaws.com (via proxy).  
debug1: channel 0: new [client-session]  
debug3: ssh\_session2\_open: channel\_new: 0  
debug2: channel 0: send open  
debug1: Requesting [no-more-sessions@openssh.com](mailto:no-more-sessions@openssh.com)  
debug1: Entering interactive session.  
debug2: callback start  
debug2: client\_session2\_setup: id 0  
debug2: channel 0: request pty-req confirm 1  
debug1: Sending environment.  
debug3: Ignored env XDG\_VTNR  
debug3: Ignored env SSH\_AGENT\_PID  
debug3: Ignored env XDG\_SESSION\_ID  
debug3: Ignored env GPG\_AGENT\_INFO  
debug3: Ignored env TERM  
debug3: Ignored env SHELL  
debug3: Ignored env VTE\_VERSION  
debug3: Ignored env CLUTTER\_DISABLE\_XINPUT  
debug3: Ignored env GJS\_DEBUG\_OUTPUT  
debug3: Ignored env WINDOWID  
debug3: Ignored env OLDPWD  
debug3: Ignored env GNOME\_KEYRING\_CONTROL  
debug3: Ignored env GJS\_DEBUG\_TOPICS  
debug3: Ignored env GTK\_MODULES  
debug3: Ignored env USER  
debug3: Ignored env http\_proxy  
debug3: Ignored env LS\_COLORS  
debug3: Ignored env XDG\_SESSION\_PATH  
debug3: Ignored env XDG\_SEAT\_PATH  
debug3: Ignored env SSH\_AUTH\_SOCK  
debug3: Ignored env ftp\_proxy  
debug3: Ignored env SESSION\_MANAGER  
debug3: Ignored env DEFAULTS\_PATH  
debug3: Ignored env XDG\_CONFIG\_DIRS  
debug3: Ignored env PATH  
debug3: Ignored env DESKTOP\_SESSION  
debug3: Ignored env PWD  
debug3: Ignored env GNOME\_KEYRING\_PID  
debug1: Sending env LANG = en\_GB.UTF-8  
debug2: channel 0: request env confirm 0  
debug3: Ignored env GDM\_LANG  
debug3: Ignored env MANDATORY\_PATH  
debug3: Ignored env https\_proxy  
debug3: Ignored env GDMSESSION  
debug3: Ignored env CINNAMON\_VERSION  
debug3: Ignored env SHLVL  
debug3: Ignored env XDG\_SEAT  
debug3: Ignored env HOME  
debug3: Ignored env LANGUAGE  
debug3: Ignored env no\_proxy  
debug3: Ignored env GNOME\_DESKTOP\_SESSION\_ID  
debug3: Ignored env LOGNAME  
debug3: Ignored env XDG\_DATA\_DIRS  
debug3: Ignored env DBUS\_SESSION\_BUS\_ADDRESS  
debug3: Ignored env GOPATH  
debug3: Ignored env LESSOPEN  
debug3: Ignored env TEXTDOMAIN  
debug3: Ignored env XDG\_RUNTIME\_DIR  
debug3: Ignored env DISPLAY  
debug3: Ignored env XDG\_CURRENT\_DESKTOP  
debug3: Ignored env LESSCLOSE  
debug3: Ignored env TEXTDOMAINDIR  
debug3: Ignored env COLORTERM  
debug3: Ignored env XAUTHORITY  
debug3: Ignored env \_  
debug2: channel 0: request shell confirm 1  
debug2: callback done  
debug2: channel 0: open confirm rwindow 0 rmax 32768  
debug2: channel\_input\_status\_confirm: type 99 id 0  
debug2: PTY allocation request accepted on channel 0  
debug2: channel 0: rcvd adjust 2097152  
debug2: channel\_input\_status\_confirm: type 99 id 0  
debug2: shell request accepted on channel 0  
Last login: Thu May 15 05:27:41 2014 from —.–.–.–  
[ec2-user@ip------------------ ~]$ exitdebug2: channel 0: rcvd eof  
debug2: channel 0: output open → drain  
debug1: client\_input\_channel\_req: channel 0 rtype exit-status reply 0  
debug1: client\_input\_channel\_req: channel 0 rtype [eow@openssh.com](mailto:eow@openssh.com) reply 0  
debug2: channel 0: rcvd eow  
debug2: channel 0: close\_read  
debug2: channel 0: input open → closed  
debug2: channel 0: rcvd close  
debug3: channel 0: will not send data after close

logout  
debug3: channel 0: will not send data after close  
debug2: channel 0: obuf empty  
debug2: channel 0: close\_write  
debug2: channel 0: output drain → closed  
debug2: channel 0: almost dead  
debug2: channel 0: gc: notify user  
debug2: channel 0: gc: user detached  
debug2: channel 0: send close  
debug2: channel 0: is dead  
debug2: channel 0: garbage collecting  
debug1: channel 0: free: client-session, nchannels 1  
debug3: channel 0: status: The following connections are open:  
#0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)

Connection to ec2-----------------.eu-west-1.compute.amazonaws.com closed.  
Transferred: sent 4144, received 2544 bytes, in 2.2 seconds  
Bytes per second: sent 1914.9, received 1175.6  
debug1: Exit status 0  
`

Thanks  
Ian

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 15, 2014, 10:25pm UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/4 "2014-05-15T22:25:00Z")

</div>

Are you creating the ec2 instances during this step or just before? It could be that they’re started but not yet accepting connections?

---

<div class="post-metadata">

**Author:** ![Ian\_Kent](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@Ian\_Kent](https://forum.ansible.com/u/Ian_Kent)\
**Post date:** [May 16, 2014, 6:26am UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/5 "2014-05-16T06:26:35Z")

</div>

The instances are already created - it probably doesn’t help that I masked all the IPs, but the EC2 instance ansible is trying to connect to is the same one I can successfully SSH to.

Just tried “-c ssh” which Michael mentioned - that fixed it, but I’m still not sure why it fails if I don’t provide that, while another playbook works fine without it.

Thanks both 🙂

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 16, 2014, 1:24pm UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/6 "2014-05-16T13:24:55Z")

</div>

Ahh, I see. Some distros like RHEL6/CentOS6 have slightly older versions of SSH that do not perform as well as paramiko. The default connection type (or transport) is “smart”, which will use paramiko for the connection if it detects an older version of SSH. As Michael said above, paramiko does not support reading the ssh\_config, so the “-c ssh” forces ansible to use the ssh connection type.

You can make this permanent by changing the "transport = " setting in your ansible.cfg to “transport = smart”.

---

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [May 16, 2014, 2:43pm UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/7 "2014-05-16T14:43:44Z")

</div>

Did you mean “transport = ssh”?

Adam

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 16, 2014, 2:57pm UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/8 "2014-05-16T14:57:10Z")

</div>

smart will select “ssh” if you have ControlMaster capability on our control machine, and will default to paramiko only if it does not.

---

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [May 16, 2014, 3:39pm UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/9 "2014-05-16T15:39:20Z")

</div>

Yes, but if he’s passing -c ssh and it fixes the issue then he might want to change from the default to transport=ssh. Otherwise it might be using paramiko which may not be what he wants.

Adam

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 16, 2014, 6:02pm UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/10 "2014-05-16T18:02:55Z")

</div>

Yes I did mean “transport = ssh”, sorry for the confusion there.

---

<div class="post-metadata">

**Author:** ![Ian\_Kent](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@Ian\_Kent](https://forum.ansible.com/u/Ian_Kent)\
**Post date:** [May 21, 2014, 3:03pm UTC](https://forum.ansible.com/t/ssh-connection-problem/15244/11 "2014-05-21T15:03:29Z")

</div>

Thanks all, I’d seen the “transport” option but hadn’t realised exactly what it meant!
