Quick Fix: ssh timeouts
It is very annoying when you leave an ssh window open to your server with something running, go to lunch, come back to see this:
Read from remote host my.stupid.server.uni.edu: Connection reset by peer.
Connection to my.stupid.server.uni.edu closed.
So here are two fixes. The first is server side.
- ssh to your server, and as root or sudo edit the file /etc/ssh/sshd_config then add the line:
This will send a timeout signal to the client every 60 seconds. The client (your desktop/laptop) is expected to be alive and answer. If it does, all is well. If not, the signals will continue every 60 seconds until a maximum count is reached (default is 3). Then the server will disconnect. So: if your client is connected and live, even if it is idle, this line in /etc/ssh/sshd_config will ensure no timeout happens. The maximum count can be set with:
ClientAliveCountMax 3 (default is 3). But you don't really need to do that. You will now need to restart your ssh server:
sudo /etc/ssh/ssh restart
sudo service ssh restart
- Alternatively, on the client side (your own desktop/laptop) edit the /etc/ssh/ssh_config (again, as root or sudo) and add the following line:
This is good for when you either don't have root on your server, or you just don't want to mess around with configuration files on the server itself.