# SSH connections to EC2 hang sporadically

**URL:** <https://forum.ansible.com/t/ssh-connections-to-ec2-hang-sporadically/16744>\
**Category:** Ansible Project\
**Created:** [November 11, 2014, 12:53pm UTC](https://forum.ansible.com/t/ssh-connections-to-ec2-hang-sporadically/16744 "2014-11-11T12:53:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tore\_Olsen](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tore\_Olsen](https://forum.ansible.com/u/Tore_Olsen)\
**Post date:** [November 11, 2014, 12:53pm UTC](https://forum.ansible.com/t/ssh-connections-to-ec2-hang-sporadically/16744/1 "2014-11-11T12:53:57Z")

</div>

Hello,

I’m having problems with SSH connections hanging seemingly indefinitely. I don’t recognize any patterns as to what tasks or handlers this happens on. I’m running ansible 1.7.1 on OS X Yosemite against a bunch of ec2 instances. I also deploy to vagrant but don’t think it has had similar SSH hangs.

Today I determined to kill -HUP the ssh process that was hung, and then ansible resumed happily.

I’d be grateful if anyone has troubleshooting tips for this.

-Tore

---

<div class="post-metadata">

**Author:** ![Tore\_Olsen](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tore\_Olsen](https://forum.ansible.com/u/Tore_Olsen)\
**Post date:** [November 14, 2014, 11:52am UTC](https://forum.ansible.com/t/ssh-connections-to-ec2-hang-sporadically/16744/2 "2014-11-14T11:52:01Z")

</div>

Just thought I’d follow up with a typical output with -vvvv; This is a play where I’m installing a couple of apt packages to three AWS hosts (shortened host1-3 for brevity). You see one of the hosts succeed while the other two apparently do not. The one that succeeds is in EU (Ireland) while the unfinished hosts are both in different AZs in East US.

I logged in to the hosts which did not resume play and verified that the temporary directory actually had been deleted.

TASK: [common | Install common packages] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
 ESTABLISH CONNECTION FOR USER: ubuntu  
 ESTABLISH CONNECTION FOR USER: ubuntu  
 ESTABLISH CONNECTION FOR USER: ubuntu  
 REMOTE\_MODULE apt pkg=git,supervisor update\_cache=yes state=present  
 REMOTE\_MODULE apt pkg=git,supervisor update\_cache=yes state=present  
 REMOTE\_MODULE apt pkg=git,supervisor update\_cache=yes state=present  
 EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ForwardAgent=yes’, ‘-o’, ‘IdentityFile=“/Users/toreo/.ssh/cargame-ssh.pem”’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, u’host2’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1415964802.72-81109603826031 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1415964802.72-81109603826031 && echo $HOME/.ansible/tmp/ansible-tmp-1415964802.72-81109603826031’”]  
 EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ForwardAgent=yes’, ‘-o’, ‘IdentityFile=“/Users/toreo/.ssh/cargame-ssh.pem”’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, u’host1’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1415964802.72-242263817184790 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1415964802.72-242263817184790 && echo $HOME/.ansible/tmp/ansible-tmp-1415964802.72-242263817184790’”]  
 EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ForwardAgent=yes’, ‘-o’, ‘IdentityFile=“/Users/toreo/.ssh/cargame-ssh.pem”’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, u’host3’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1415964802.72-65992156942899 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1415964802.72-65992156942899 && echo $HOME/.ansible/tmp/ansible-tmp-1415964802.72-65992156942899’”]  
 PUT /var/folders/f6/hp9f9y0933q95\_9mlbhk27dm0000gn/T/tmpQGGHOr TO /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-65992156942899/apt  
 PUT /var/folders/f6/hp9f9y0933q95\_9mlbhk27dm0000gn/T/tmp38enSO TO /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-242263817184790/apt  
 PUT /var/folders/f6/hp9f9y0933q95\_9mlbhk27dm0000gn/T/tmpYViEBl TO /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-81109603826031/apt  
 EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ForwardAgent=yes’, ‘-o’, ‘IdentityFile=“/Users/toreo/.ssh/cargame-ssh.pem”’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, u’host3’, u’/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=uuhortuzkrrxndipfnakoyezwvmlbrrg] password: " -u root /bin/sh -c '”'“'echo SUDO-SUCCESS-uuhortuzkrrxndipfnakoyezwvmlbrrg; LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-65992156942899/apt; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-65992156942899/ \>/dev/null 2\>&1'”'“''']  
 EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ForwardAgent=yes’, ‘-o’, 'IdentityFile=”/Users/toreo/.ssh/cargame-ssh.pem"‘, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, u’host1’, u’/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=kmkiimakutvlojnbqartowszmpdbndzk] password: " -u root /bin/sh -c '”'“'echo SUDO-SUCCESS-kmkiimakutvlojnbqartowszmpdbndzk; LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-242263817184790/apt; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-242263817184790/ \>/dev/null 2\>&1'”'“''']  
 EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ForwardAgent=yes’, ‘-o’, 'IdentityFile=”/Users/toreo/.ssh/cargame-ssh.pem"‘, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, u’host2’, u’/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=iyzsrbntouwziaxcxllqidtsopvifmac] password: " -u root /bin/sh -c '”'“'echo SUDO-SUCCESS-iyzsrbntouwziaxcxllqidtsopvifmac; LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-81109603826031/apt; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-81109603826031/ \>/dev/null 2\>&1'”'"''']  
ok: [host3] =\> (item=git,supervisor) =\> {“changed”: false, “item”: “git,supervisor”}

---

<div class="post-metadata">

**Author:** ![Tore\_Olsen](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tore\_Olsen](https://forum.ansible.com/u/Tore_Olsen)\
**Post date:** [November 14, 2014, 12:01pm UTC](https://forum.ansible.com/t/ssh-connections-to-ec2-hang-sporadically/16744/3 "2014-11-14T12:01:24Z")

</div>

If it helps, I just kill -HUP’ed one of the ssh processes and got a lot of debug output:

failed: [host1] =\> (item=git,supervisor) =\> {“failed”: true, “item”: “git,supervisor”, “parsed”: false}

invalid output was: SUDO-SUCCESS-kmkiimakutvlojnbqartowszmpdbndzk

OpenSSH\_6.2p2, OSSLShim 0.9.8r 8 Dec 2011

debug1: Reading configuration data /Users/toreo/.ssh/config

debug1: Reading configuration data /etc/ssh\_config

debug1: /etc/ssh\_config line 20: Applying options for \*

debug1: /etc/ssh\_config line 53: Applying options for \*

debug2: ssh\_connect: needpriv 0

debug1: Connecting to host1 [] port 22.

debug2: fd 3 setting O\_NONBLOCK

debug1: fd 3 clearing O\_NONBLOCK

debug1: Connection established.

debug3: timeout: 9894 ms remain after connect

debug3: Incorrect RSA1 identifier

debug3: Could not load “/Users/toreo/.ssh/cargame-ssh.pem” as a RSA1 public key

debug1: identity file /Users/toreo/.ssh/cargame-ssh.pem type -1

debug1: identity file /Users/toreo/.ssh/cargame-ssh.pem-cert type -1

debug1: Enabling compatibility mode for protocol 2.0

debug1: Local version string SSH-2.0-OpenSSH\_6.2

debug1: Remote protocol version 2.0, remote software version OpenSSH\_6.6.1p1 Ubuntu-2ubuntu2

debug1: match: OpenSSH\_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH\*

debug2: fd 3 setting O\_NONBLOCK

debug3: load\_hostkeys: loading entries for host “host1” from file “/Users/toreo/.ssh/known\_hosts”

debug3: load\_hostkeys: found key type RSA in file /Users/toreo/.ssh/known\_hosts:42

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: 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,ssh-dss-cert-v01@openssh.com,ssh-dss-cert-v00@openssh.com,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: [zlib@openssh.com](mailto:zlib@openssh.com),zlib,none

debug2: kex\_parse\_kexinit: [zlib@openssh.com](mailto:zlib@openssh.com),zlib,none

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: [curve25519-sha256@libssh.org](mailto:curve25519-sha256@libssh.org),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,ssh-dss,ecdsa-sha2-nistp256

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,chacha20-poly1305@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,chacha20-poly1305@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)

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-etm@openssh.com](mailto:hmac-md5-etm@openssh.com)

debug1: kex: server-\>client aes128-ctr [hmac-md5-etm@openssh.com](mailto:hmac-md5-etm@openssh.com) [zlib@openssh.com](mailto:zlib@openssh.com)

debug2: mac\_setup: found [hmac-md5-etm@openssh.com](mailto:hmac-md5-etm@openssh.com)

debug1: kex: client-\>server aes128-ctr [hmac-md5-etm@openssh.com](mailto:hmac-md5-etm@openssh.com) [zlib@openssh.com](mailto:zlib@openssh.com)

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: 494/1024

debug1: SSH2\_MSG\_KEX\_DH\_GEX\_INIT sent

debug1: expecting SSH2\_MSG\_KEX\_DH\_GEX\_REPLY

debug1: Server host key: RSA 90:5b:60:eb:fd:c3:96:b1:83:b7:9f:5e:b4:bd:c0:b3

debug3: load\_hostkeys: loading entries for host “host1” from file “/Users/toreo/.ssh/known\_hosts”

debug3: load\_hostkeys: found key type RSA in file /Users/toreo/.ssh/known\_hosts:42

debug3: load\_hostkeys: loaded 1 keys

debug3: load\_hostkeys: loading entries for host “” from file “/Users/toreo/.ssh/known\_hosts”

debug3: load\_hostkeys: found key type RSA in file /Users/toreo/.ssh/known\_hosts:42

debug3: load\_hostkeys: loaded 1 keys

debug1: Host ‘host1’ is known and matches the RSA host key.

debug1: Found key in /Users/toreo/.ssh/known\_hosts:42

debug2: bits set: 519/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: /Users/toreo/.ssh/id\_rsa (0x7f816ab01280),

debug2: key: /Users/toreo/.ssh/cargame-ssh.pem (0x0), explicit

debug1: Authentications that can continue: publickey

debug3: start over, passed a different list publickey

debug3: preferred gssapi-with-mic,gssapi-keyex,hostbased,publickey

debug3: authmethod\_lookup publickey

debug3: remaining preferred: ,gssapi-keyex,hostbased,publickey

debug3: authmethod\_is\_enabled publickey

debug1: Next authentication method: publickey

debug1: Offering RSA public key: /Users/toreo/.ssh/id\_rsa

debug3: send\_pubkey\_test

debug2: we sent a publickey packet, wait for reply

debug1: Authentications that can continue: publickey

debug1: Trying private key: /Users/toreo/.ssh/cargame-ssh.pem

debug1: read PEM private key done: type RSA

debug3: sign\_and\_send\_pubkey: RSA fd:98:17:09:b8:20:08:c2:66:d9:54:07:e6:04:b9:23

debug2: we sent a publickey packet, wait for reply

debug1: Enabling compression at level 6.

debug1: Authentication succeeded (publickey).

Authenticated to host1 ([]:22).

debug2: fd 6 setting O\_NONBLOCK

debug2: fd 7 setting O\_NONBLOCK

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

debug1: Requesting authentication agent forwarding.

debug2: channel 0: request [auth-agent-req@openssh.com](mailto:auth-agent-req@openssh.com) confirm 0

debug2: fd 3 setting TCP\_NODELAY

debug3: packet\_set\_tos: set IP\_TOS 0x10

debug2: client\_session2\_setup: id 0

debug2: channel 0: request pty-req confirm 1

debug1: Sending environment.

debug3: Ignored env VIRTUALENVWRAPPER\_PROJECT\_FILENAME

debug3: Ignored env TERM\_PROGRAM

debug3: Ignored env TERM

debug3: Ignored env SHELL

debug3: Ignored env TMPDIR

debug3: Ignored env Apple\_PubSub\_Socket\_Render

debug3: Ignored env TERM\_PROGRAM\_VERSION

debug3: Ignored env TERM\_SESSION\_ID

debug3: Ignored env USER

debug3: Ignored env SSH\_AUTH\_SOCK

debug3: Ignored env \_\_CF\_USER\_TEXT\_ENCODING

debug3: Ignored env WORKON\_HOME

debug3: Ignored env PATH

debug3: Ignored env VIRTUALENVWRAPPER\_HOOK\_DIR

debug3: Ignored env PWD

debug3: Ignored env XPC\_FLAGS

debug3: Ignored env PS1

debug3: Ignored env XPC\_SERVICE\_NAME

debug3: Ignored env HOME

debug3: Ignored env SHLVL

debug3: Ignored env LOGNAME

debug1: Sending env LC\_CTYPE = UTF-8

debug2: channel 0: request env confirm 0

debug3: Ignored env GOPATH

debug3: Ignored env DISPLAY

debug3: Ignored env VIRTUALENVWRAPPER\_LOG\_DIR

debug3: Ignored env SECURITYSESSIONID

debug3: Ignored env OLDPWD

debug3: Ignored env \_

debug3: Ignored env VERSIONER\_PYTHON\_VERSION

debug3: Ignored env VERSIONER\_PYTHON\_PREFER\_32\_BIT

debug1: Sending command: /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=kmkiimakutvlojnbqartowszmpdbndzk] password: " -u root /bin/sh -c '”’“‘echo SUDO-SUCCESS-kmkiimakutvlojnbqartowszmpdbndzk; LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-242263817184790/apt; rm -rf /home/ubuntu/.ansible/tmp/ansible-tmp-1415964802.72-242263817184790/ \>/dev/null 2\>&1’”‘"’’

debug2: channel 0: request exec 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: exec request accepted on channel 0

debug1: channel 0: free: client-session, nchannels 1

debug3: channel 0: status: The following connections are open:

#0 client-session (t4 r0 i0/0 o0/0 fd 5/6 cc -1)

debug1: fd 1 clearing O\_NONBLOCK

debug1: fd 2 clearing O\_NONBLOCK

Killed by signal 1.

---

<div class="post-metadata">

**Author:** ![Wawrzek\_Niewodniczan](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@Wawrzek\_Niewodniczan](https://forum.ansible.com/u/Wawrzek_Niewodniczan)\
**Post date:** [November 17, 2014, 9:19am UTC](https://forum.ansible.com/t/ssh-connections-to-ec2-hang-sporadically/16744/4 "2014-11-17T09:19:42Z")

</div>

I’m checking output of your commands on the phone in the bus so I could miss something, but it looks like ssh is actually fine. Have you try to debug on remote host?

Have you compare ansible with normal ssh?

Cherers,  
Wawrzek

---

<div class="post-metadata">

**Author:** ![Tore\_Olsen](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tore\_Olsen](https://forum.ansible.com/u/Tore_Olsen)\
**Post date:** [November 17, 2014, 10:16am UTC](https://forum.ansible.com/t/ssh-connections-to-ec2-hang-sporadically/16744/5 "2014-11-17T10:16:04Z")

</div>

Hi Wawrzek,

Thanks for your response. I believe my problem may have been caused by SSH connections being silently broken by NAT. I just added “ServerAliveInterval 50” to my ~/.ssh/config file and will see how it works out. Regular SSH connections would sometimes fail with a broken pipe, but of couse that happened because I would type something. Ansible is just waiting for data from the peer, so it won’t detect this situation.

Unless I follow up with more information, I think we can consider this solved.

-Tore
