SSH connection closed/dropped a few seconds after successful log in (EC2/linux/debian)

amazon ec2connectionsshtimeout

I have been using ssh to connect to the same EC2 instance for months. Now, all of a sudden, I am getting kicked off the server every time I try to do so. The amount of time I can remain connected varies, but generally seems to be on the range of 1-25 seconds. All settings are the same as they were when things were working smoothly. The problem has persisted for over a week at this point. Nothing else seems to be out of the ordinary. While connected, I have full access to the server.

I set the server log to DEBUG3, and am seeing this message:

Read error from remote host [my ip address]: Connection timed out

All the following are at high/normal values:

/proc/sys/net/ipv4/tcp_keepalive_time
/proc/sys/net/ipv4/tcp_keepalive_intvl
/proc/sys/net/ipv4/tcp_keepalive_probes 

sshd_config: has TCPKeepAlive set to yes.

Best Answer

Have you added any networking or proxy services between you and the EC2 instance recently? I've seen similar behavior when a new firewall was introduced and the NAT sessions were being quickly dumped during an active session. That is unlikely but I've seen that.

Have you tried a traceroute or ping test between your location and the EC2 instance to see if there is a point of intermittent failure between your two locations?

Is this behavior the same at your office location, a coffee shop and home? Have you tried on completely different networks to see if that shows a difference?

Are the systems in question in a load balanced set or other interesting network services from Amazon?

I am interested in hearing how it turns out.