Monday, August 7, 2017

ssh timeout with ec2 aws instance

While reading some posts such as this I realized that aws cuts your connection after only 60 seconds of inactivity. This became annoying, so I decided to follow some of the recommendations in the posts I came across and this worked for me. There are two ways to do this: one is by changing the ssh configuration in the  server by keeping all client connections alive as follows:

open the file /etc/ssh/sshd_config on the virtual machine

add the lines at the end of the file

ClientAliveInterval 50
ClientAliveCountMax 10


restart the service or reboot the system

sudo service ssh restart



The other way is to keep any server alive by changing the ssh configuration on the client machine or local machine. To do it for all users in the local machine open the file


sudo vi /etc/ssh/ssh_config
add the following line under the host * section:

ServerAliveInterval 50