Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 
like image 660
Roberto Avatar asked Aug 26 '11 20:08

Roberto


People also ask

How do I increase SSH inactivity timeout?

Set the keep-alive options in the client configuration file: Login to the client machine and open the /etc/ssh/ssh_config file to set the necessary parameter values to increase the SS connection timeout. ServerAliveInterval and ServerAliveCountMax parameters are set to increase the connection timeout.

Why is my SSH connection timed out?

This error message comes from the SSH client. The error indicates that the server didn't respond to the client and the client program gave up (timed out). The following are common causes for this error: The security group or network ACL doesn't allow access.

What is SSH idle timeout?

SSH allows administrators to set an idle timeout interval. After this interval has passed, the idle user will be automatically logged out. To set an idle timeout interval, edit the following line in "/etc/ssh/sshd_config" as follows: ClientAliveInterval [interval] The timeout [interval] is given in seconds.


1 Answers

You can set a keep alive option in your ~/.ssh/config file on your computer's home dir:

ServerAliveInterval 50 

Amazon AWS usually drops your connection after only 60 seconds of inactivity, so this option will ping the server every 50 seconds and keep you connected indefinitely.

like image 58
mauriciomdea Avatar answered Oct 05 '22 09:10

mauriciomdea