How to Extend SSH Timeout on CentOS Server

This article explains how to increase the SSH timeout length on CentOS servers. In this example CentOS 6.7 is used. The first thing you need to do is edit the file located /etc/ssh/sshd_config

nano /etc/ssh/sshd_config

  Uncomment these lines: (Located nearer the bottom of the file)

#ClientAliveInterval 0 
#ClientAliveCountMax 3

  Now edit the values so they look something more like this

ClientAliveInterval 180 
ClientAliveCountMax 10

  ClientAliveInterval 180 would result in SSH sending KeepAlive packets in 180 second intervals. Should SSH not recieve a response back back from the client then it will retry a further 10 times, which is what ClientAliveCountMax 10 is for. It is the number of KeepAlive retries. So overall using these values it should stay open for 30 minutes after your last interaction. Finally, you should now restart the ssh service:

service sshd restart

  The response should be:

Stopping sshd:            [ OK ] 
Starting sshd:            [ OK ]

Author: Josh Burley

Over 10 years software and website development, more recently moving into app development. Became a founding member and managing partner of WebDesires in late 2014 early 2015. Now dedicate most of my time to the company and helping us grow into the industry.

Leave a Reply

Your email address will not be published. Required fields are marked *