Search code examples
sshamazon-ec2amazon-web-services

Amazon EC2 ssh timeout due inactivity


I am able to issue commands to my EC2 instances via SSH and these commands logs answers which I'm supposed to keep watching for a long time. The bad thing is that SSH command is closed after some time due to my inactivity and I'm no longer able to see what's going on with my instances.

How can I disable/increase timeout in Amazon Linux machines?

The error looks like this:

Read from remote host ec2-50-17-48-222.compute-1.amazonaws.com: Connection reset by peer

Solution

  • Consider using screen or byobu and the problem will likely go away. What's more, even if the connection is lost, you can reconnect and restore access to the same terminal screen you had before, via screen -r or byobu -r.

    byobu is an enhancement for screen, and has a wonderful set of options, such as an estimate of EC2 costs.