SSH clients will automatically be disconnected from the server and prompt the below message after being idle or inactive for a while.
Read from remote host oseems.com: Connection reset by peer Connection to oseems.com closed.
This is due to the SSH servers' configuration (often by default) to avoid hanging sessions and free up resources. These are the related options in the SSH server configuration;
alivemessage to clients if no data has been received from connection. Defaults to
0(not sending any message).
alivemessage before disconnecting clients if no response are received. Defaults to
If you have administrative access to the SSH servers, you can change the options so that you will not easily be disconnected. Edit the SSH server configuration file (normally in
/etc/ssh/sshd_config for Unix based operating systems) and set the related options as the followings (uncomment or add if necessary);
TCPKeepAlive no ClientAliveInterval 30 ClientAliveCountMax 240
What it basically means is that the server will not send the TCP
alive packet to check if the client's connection is working, yet will still send the encrypted
alive message every 30 seconds but will only disconnect after at least 2 hours of inactivity. Be sure to restart the SSH service after the reconfiguration.
If you don't have administrative access to the server, you can configure the SSH client to send the
alive message to the server instead. The key here is the
ServerAliveInterval option for the SSH client.
You can do this by updating
/etc/ssh/ssh_config (applying the setting to every user in the system) or in
~/.ssh/config (single user). Set the following option to have the client send the
alive packet every 30 seconds to the server;
The other alternative is to manually set the
ServerAliveInterval option every time you're connecting to a server by using the
-o ServerAliveInterval=<time-in-second> prefix as the following example;
$ ssh -o ServerAliveInterval=30 email@example.com