Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Disable/Fix SSH Timeouts On Ubuntu Server

If you get even remotely as annoyed as I do when SSH times out and disconnects then this post is for you. Below is how to quickly and easily fix the SSH timeout issue. This solution will not disable the timeouts entirely though, instead it just sets the threshold extremely high.

First lets make a copy of your sshd configuration file by running the following:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

Next lets open up the sshd_config file with vi, you can use nano or another text editor if you prefer:

sudo vi /etc/ssh/sshd_config

If you are not used to vi or any other terminal based text editor then I will try to make life easier for you in the next few steps. Press the “i” button on your keyboard to enter insert mode and then navigate with the arrow keys until you find the following lines:

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

Add the following information below it:

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# FIX TIMEOUT ISSUES
TCPKeepAlive no
ClientAliveInterval 30
ClientAliveCountMax 240

Now that we have added the entries, save the changes by pressing the escape key (esc) and then entering “:wq” followed by pressing enter. Last but not least we will restart the sshd service so the changes can take effect. (Your current ssh session will remain active and unchanged, but when you reconnect the changes will take effect.)

sudo service sshd restart

Congratulations, your SSH sessions will no longer timeout unless you leave your session untouched for around a day or so. Please don’t forget to like/comment/share!



This post first appeared on Teach Me Linux, please read the originial post: here

Share the post

Disable/Fix SSH Timeouts On Ubuntu Server

×

Subscribe to Teach Me Linux

Get updates delivered right to your inbox!

Thank you for your subscription

×