This article covers different ways of keeping SSH sessions alive and preventing them from needlessly timing out. These are handy tips that you can use especially when there are no associated risks with someone taking over your SSH session when you are away. SSH sessions will timeout and the client will automatically be disconnected from the server after being idle or inactive for a while.
To Avoid SSH timeout from the server:
1. Edit SSHd configuration file using your favorite editor,
$ sudo vi /etc/ssh/sshd_config
2. Set these options as the followings:
Here, 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. It will only disconnect after at least 2 hours of inactivity.