How to disable SSH timeout on Centos 7?

Apply on:Redhat 7/Centos 7

PROBLEM:

Open SSH Server connection drops out after few or N minutes of inactivity on vmware.

How to prevent ssh from disconnecting if it’s been idle for a while?

After few minutes ssh disconnect on redhat 7/centos 7.

[root@server1 ~]# tail -f /var/log/secure

Nov 15 13:39:02 server1 polkitd[4245]: Unregistered Authentication Agent for unix-process:5920:869643 (system bus name :1.194, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)

SOLUTION:

Add following on  /etc/ssh/sshd_config and /etc/ssh/ssh_conf file restart the sshd service.

1.vi /etc/ssh/sshd_config       #after 3600 second disconnect

TCPKeepAlive no
ClientAliveInterval 30
ClientAliveCountMax 3600

2. systemctl restart sshd.service

3.vi /etc/ssh/ssh_config          #applying the setting to every user in the system.

ServerAliveInterval 30

OR

4. vi  ~/.ssh/config                     #applying the setting to single user in the system.

ServerAliveInterval 30

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s