Reputation: 20625
I used putty on windows to connect ssh to my droplet of Digitaloccean, but ssh session will expire after a short inactivity. What configuration I need to prolong the session timeout?
Upvotes: 4
Views: 15837
Reputation: 1618
To prevent all your clients from timing out you need to edit /etc/sshd_config
which is the server-side configuration file add these two options:
ClientAliveInterval 120
ClientAliveCountMax 720
The first one configures the server to send null packets
to clients every 120 seconds and the second one configures the server to close the connection if the client has been inactive for 720 intervals that are 720*120 = 86400 seconds = 24 hours
Upvotes: 7
Reputation: 5145
CD /etc/ grep -R TMOUT Comment out all the lines in all the files displayed in above grep output.
Upvotes: -3
Reputation: 188
Screenshot of Windows putty client configuration with TCP KeepAlive enabled:
Please don't forget to save the session configuration!!! :-)
Upvotes: 1
Reputation: 20625
There are 2 places you need to set configuration for: TESTED WORKING
Client config:
-Open file /etc/ssh/ssh_config and set directive ServerAliveInterval to a value like 100 for example:
# other configs
ServerAliveInterval 100
This causes your SSH client to send keep-alive messages every 100 seconds so that the server doesn't drop your connection.
Server config
-Open file /etc/ssh/sshd_config and add these configurations at the end of the file to ensure they're not overriden by later lines:
# other configs
ClientAliveInterval 600
TCPKeepAlive yes
ClientAliveCountMax 10
These are conservative settings that will make your SSH Server only disconnect after (600 * 10 = 6000) seconds of user inactivity. Customize these if you need more.
Restart the ssh server so that changes take effect:
$ sudo /etc/init.d/ssh restart
Source: http://queirozf.com/entries/disabling-ssh-timeout-when-connecting-to-from-ubuntu
Upvotes: 8