Saturday, 16 April 2016

How to increase SSH connection timeout ?


What is SSH timeout problem ?
After login in to the shell many time shell remain idle and due to that SSH connection closed by the server and we have to re-login in to the shell.
You may be using some tool to login in shell, Like : PuTTY


Solution

We can avoid this problem by increasing the SSH timeout in the servers main sshd configuration file.
Step 1. Login in to the server as root user.

Step 2. Run the following command for opening sshd configuration :
[root@server ~]# vi /etc/ssh/sshd_config

Step 3. Search the line “ClientAliveInterval” and change it as,
ClientAliveInterval  3600
[ Here, we have used 3600 seconds, so that SSH won’t disconnect within set 3600 seconds value while remaining idle ]

Step 4. Restart the SSHD service to reload the new sshd configuration values.
[root@server ~]# /sbin/service sshd restart

Please refer to the below genius post to know more about restarting sshd service.



How do I restart sshd service ?

After you change the configuration on your remote Linux or Unix server you must restart your SSH service.
Easiest way to do this - simply restart your Linux machine, which is not always possible however.

Other way - To restart sshd without restarting your whole system, enter the following command as root user :
RedHat and Fedora Core Linux
# /sbin/service sshd restart

Suse linux
# /etc/rc.d/sshd restart

Debian/Ubuntu
# /etc/init.d/sshd restart

Solaris 9 and below
# /etc/init.d/sshd stop
# /etc/init.d/sshd start

Solaris 10
# svcadm disable ssh
# svcadm enable ssh

AIX
# stopsrc -s sshd
# startsrc -s sshd

HP-UX
# /sbin/init.d/secsh stop
# /sbin/init.d/secsh start

No comments:

Post a Comment

Note: only a member of this blog may post a comment.