Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-20-2012, 08:32 AM
|
#1
|
LQ Newbie
Registered: May 2011
Posts: 9
Rep:
|
how to disable auto logout
Hi Friends,
My box has RHEL 5.7, my problem is the ssh terminal gets disconnected after 1 hour.
the sshd_config file have the below lines commented
#LoginGraceTime 2m
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none
and when try " echo $TMOUT " i get an null output
and i was not able to find the TMOUT option in /etc/profile, ~.bash_profile or ~.bashrc and still i get logged out exactly after 1 hour.
hope someone will have suggestions
|
|
|
06-20-2012, 08:42 AM
|
#2
|
Member
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347
Rep:
|
These parameter are used for ssh connection timeout in /etc/sshd_config:
Code:
ClientAliveInterval N
ClientAliveCountMax N
TCPKeepAlive yes
So remove the comment to TCPKeepAlive yes and set high values for ClientAliveInterval and ClientAliveCountMax (removing comments to relative lines too).
|
|
1 members found this post helpful.
|
06-20-2012, 04:31 PM
|
#3
|
Member
Registered: May 2010
Location: UK
Distribution: RHEL6
Posts: 70
Rep:
|
I thought if ClientAliveInterval was set to the default of zero then these messages are not sent and no timeout and disconnect of idle ssh sessions is configured. So I'm not sure this is the issue in this case.
Did the changes suggested solve your issue?
Is the ssh client connecting directly or are there any firewalls in-between?
I know you mention this is affecting ssh clients, but do console sessions also get logged out after an hour?
Have you checked if there is any timeout set on your ssh client?
(There is a ServerAliveInterval for ssh_config, which you might want to review)
Is this the only RHEL host with this issue?
Have you tested from a different ssh client?
For ensuring an ssh connection remains in place you could look at something like autossh:
http://noone.org/blog/English/Comput...0Screen.futile
Hope this helps.
|
|
|
06-21-2012, 12:33 AM
|
#4
|
Member
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347
Rep:
|
According to the sshd_config manpage ClientAliveInterval "Sets a timeout interval in seconds after which if no data has been received from the client, sshd will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client."
So if you set ClientAliveInterval to 0 NO request message will be sent.
|
|
|
06-21-2012, 01:23 AM
|
#5
|
LQ Newbie
Registered: May 2011
Posts: 9
Original Poster
Rep:
|
Hi Bros thanks ,
I set it as given below - for 2 hrs
TCPKeepAlive yes
ClientAliveInterval 7200
ClientAliveCountMax 3
still no luck, it just logged out exactly after one hour.
ssh is connecting through firewall - which has set rule for 2hrs, so not related to network
even i tested from other clients - no luck
direct console am not getting logged out.
couldn't find any options to set in ssh clinets.
i tried adding " export TMOUT=0 " - still same
|
|
|
06-21-2012, 01:41 AM
|
#6
|
Member
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347
Rep:
|
Try this:
Code:
TCPKeepAlive yes
ClientAliveInterval 30
ClientAliveCountMax 3000
In this way every 30 seconds when in idle the server will sent a request. It'll continue doing so for 3000 times.
30 secs x 3000 = 90000 secs = 250 mins = 4.166 hrs
If you use a too high value in ClientAliveInterval the request can be sent too late and it's possible that is the client closing connections (not the server).
You can even configure the ssh client (ssh_config) setting ServerAliveInterval on the clint e.g. to 60.
|
|
|
06-21-2012, 02:37 AM
|
#7
|
Moderator
Registered: May 2001
Posts: 29,415
|
Use AutoSSH instead?
|
|
|
06-21-2012, 03:41 AM
|
#8
|
Member
Registered: May 2010
Location: UK
Distribution: RHEL6
Posts: 70
Rep:
|
Quote:
Originally Posted by Slackyman
According to the sshd_config manpage ClientAliveInterval "Sets a timeout interval in seconds after which if no data has been received from the client, sshd will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client."
So if you set ClientAliveInterval to 0 NO request message will be sent.
|
That's exactly my point, the OP listed his sshd_config and this was not set, so it must be at the default of 0, which means this should not be in effect.
|
|
|
06-21-2012, 03:52 AM
|
#9
|
Member
Registered: May 2010
Location: UK
Distribution: RHEL6
Posts: 70
Rep:
|
Quote:
Originally Posted by smshvp
Hi Bros thanks ,
ssh is connecting through firewall - which has set rule for 2hrs, so not related to network
even i tested from other clients - no luck
direct console am not getting logged out.
couldn't find any options to set in ssh clinets.
i tried adding " export TMOUT=0 " - still same
|
I know you've mentioned the firewall config, but were these other clients also the other side of the firewall?
Is this the only server this issue is occurring on?
What ssh client are you using?
On the RHEL system console you could try:
Code:
ssh localhost
- Wait an hour and see if it disconnects
ssh <server IP>
- Could also try the server IP address and wait an hour
If neither of these disconnect after an hour then I don't think it is related to any config on your server - it is then most likely either your ssh client config or something like a firewall.
Hope this helps.
|
|
|
06-21-2012, 05:35 AM
|
#10
|
LQ Newbie
Registered: May 2011
Posts: 9
Original Poster
Rep:
|
Slackyman...thanks a lot..that did the trick, now its fine, changed my settings in the "sshd_config" file as you said
TCPKeepAlive yes
ClientAliveInterval 30
ClientAliveCountMax 3000
this 4 hours is okey for me, i can extend it as required in future .
i am using ssh client from windows machine...and i found the sshd_config file but everything is commented in it
and tried changing the time but didn't work.but changing in server sshd_config it's working....thanks a lot
i checked other servers too with the default settings, i think it's the same in all servers with various versions.
unSpawn :thanks..came to know about new sol.
maccas17 :let me check the one you mentioned with other servers, will update you.
|
|
|
06-21-2012, 05:58 AM
|
#11
|
Member
Registered: May 2010
Location: UK
Distribution: RHEL6
Posts: 70
Rep:
|
Quote:
i am using ssh client from windows machine...and i found the sshd_config file but everything is commented in it
|
I'm a bit confused where the original sshd_config values in your first post came from?
If ClientAliveInterval was indeed set to 0 then I don't see how this was causing the original disconnect issue.
Through setting them you have now enabled idle setting disconnect as per the ~4 hours Slackyman illustrated.
Quote:
unSpawn :thanks..came to know about new sol.
|
I already suggested AutoSSH in my earlier post
Quote:
maccas17 :let me check the one you mentioned with other servers, will update you.
|
I would be very interested to hear if you find out anything further when testing this out.
Glad you've got a solution at any rate
|
|
|
All times are GMT -5. The time now is 07:27 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|