Tip: Prevent SSH Session from Disconnecting
The network connection at office keeps my SSH session from running smoothly. Well, it means I keep on being disconnected from the server when my SSH session turns idle for a certain period of time. It gets annoying especially if I am in the middle of a script running silently.
One alternative I have written before here is using screen command or by editing the SSH config file to prevent SSH from disconnecting its connection.
The process is very simple: your SSH session consistently sends packets over the connection to let the remote computer know that the session is still active and there is no need for termination. This is what they call Keep Alive packets. For me, it means Keep My Sanity packets.
Anyway here is what you need to do. Edit your ssh_config file, usually in /etc/ssh/ directory:
# vi /etc/ssh/ssh_config
And put this line in the file:
ServerAliveInterval 60
Save and exit.
Open the ~/.ssh/config file (or create it if not present) and put this line in it:
Host *
ServerAliveInterval 60
Don’t forget the indent at the second line. Save and exit.
Lastly, reload your new SSH config file by doing:
# /etc/init.d/sshd reload
This should do the trick of fooling the remote server into thinking that your SSH connection is active, even if it is not.
Did this tip worked for you? Let me know in the comments section.
Related Posts
1 Comment to “Tip: Prevent SSH Session from Disconnecting”
Post comment
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- chyrica
on Cebu Pacific Sucks - chyrica
on Cebu Pacific Sucks - wallpat
on Cool Ubuntu-Filipino Wallpapers - celebrity fuck you
on Diablo 3 Coming Soon - Dakbayani
on Bayanihan Linux: True Blue Pinoy Linux









/etc/ssh/ssh_config is the client config file. Restarting the sshd server (/etc/init.d/sshd reload) does nothing regarding that file. Simply running ssh will cause the client to read the config. If you had changed /etc/ssh/sshd_config (the server config), then the server reload would do something.