WebDesires

How to Extend SSH Timeout on CentOS Server

Need Some Help? We are here for you!

We have a very friendly service - Come and chat to us and let us know what you need, we work for an hourly fee and can also provide you a no obligation quote and begin work immediately in most cases. Click "Request Support" or use our Live Chat.

Request Support
There is a mobile optimized version of this page, view AMP Version.

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 ]

Need Some Help? We are here for you!

We have a very friendly service - Come and chat to us and let us know what you need, we work for an hourly fee and can also provide you a no obligation quote and begin work immediately in most cases. Click "Request Support" or use our Live Chat.

Request Support

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.