System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

ssh session gets hung after remaining idle for few hours or minutes

 
Indrajit Bhagat
Regular Advisor

ssh session gets hung after remaining idle for few hours or minutes

Hello Experts,

 

I had two servers , where one server ssh connection is not getting timeout and is remaning live even after accessing after few hours.

 

And in one server, ssh session gets hung if the session remains idle. (This is problem)

 

May i have an solution for the same.

2 REPLIES
Laurent Menase
Honored Contributor

Re: ssh session gets hung after remaining idle for few hours or minutes

Hi Indrajit,

any firewall between the server and client?

 

Else they can use Alive options of ssh

man ssh_config

     ServerAliveInterval

ServerAliveCountMax

 

man sshd_config

ClientAliveCountMax

ClientAliveInterval

 

Bill Hassell
Honored Contributor

Re: ssh session gets hung after remaining idle for few hours or minutes

You could also add the TMOUT variable to .profile so the shell will timeout and disconnect:

export TMOUT=3600

This will timeout with no typing in the shell after 60 minutes (3600 seconds).

(this assumes that your shell is ksh, POSIX sh or bash)



Bill Hassell, sysadmin