LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 06-20-2012, 08:32 AM   #1
smshvp
LQ Newbie
 
Registered: May 2011
Posts: 9

Rep: Reputation: Disabled
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
 
Old 06-20-2012, 08:42 AM   #2
Slackyman
Member
 
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
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.
Old 06-20-2012, 04:31 PM   #3
maccas17
Member
 
Registered: May 2010
Location: UK
Distribution: RHEL6
Posts: 70

Rep: Reputation: 11
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.
 
Old 06-21-2012, 12:33 AM   #4
Slackyman
Member
 
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
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.
 
Old 06-21-2012, 01:23 AM   #5
smshvp
LQ Newbie
 
Registered: May 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
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
 
Old 06-21-2012, 01:41 AM   #6
Slackyman
Member
 
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
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.
 
Old 06-21-2012, 02:37 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Use AutoSSH instead?
 
Old 06-21-2012, 03:41 AM   #8
maccas17
Member
 
Registered: May 2010
Location: UK
Distribution: RHEL6
Posts: 70

Rep: Reputation: 11
Quote:
Originally Posted by Slackyman View Post
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.
 
Old 06-21-2012, 03:52 AM   #9
maccas17
Member
 
Registered: May 2010
Location: UK
Distribution: RHEL6
Posts: 70

Rep: Reputation: 11
Quote:
Originally Posted by smshvp View Post
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.
 
Old 06-21-2012, 05:35 AM   #10
smshvp
LQ Newbie
 
Registered: May 2011
Posts: 9

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-21-2012, 05:58 AM   #11
maccas17
Member
 
Registered: May 2010
Location: UK
Distribution: RHEL6
Posts: 70

Rep: Reputation: 11
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-Logout of X-Windows Abnoba12 Linux - Newbie 8 11-08-2006 10:01 AM
How to disable auto-logout when running custom rc.local script? Arodef Linux - General 0 05-17-2006 05:02 PM
Auto logout problem Dubious Dave LQ Suggestions & Feedback 2 05-02-2006 10:35 AM
auto logout sysfriend Linux - Newbie 1 12-06-2005 03:20 PM
auto logout ziox Linux - General 1 11-21-2004 06:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration