LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 12-29-2011, 11:26 PM   #1
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,188
Blog Entries: 4

Rep: Reputation: 220Reputation: 220Reputation: 220
SSH disconnects when inactive


Hello All,

I am using RHEL 5.2 and this is quite surprising situation when I use putty to connect to my remote machine it regularly gets disconnected when kept inactive for few minutes then I need to relogin to start my work.

But again this happens with only one server and all the other servers in which I login, there is no such problem.

I did a bit google and came up with this site

http://www.walkernews.net/2008/05/11...-disconnected/

But my concern is why ut happens with only one server?

Is my sshd_config has any thing to do with it?
Kindly tell me where to look out for the solution
 
Old 12-29-2011, 11:33 PM   #2
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 189Reputation: 189
Some things to check in sshd_config

TCPKeepAlive, ClientAliveCountMax, ClientAliveInterval.
 
Old 12-29-2011, 11:48 PM   #3
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,188
Blog Entries: 4

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by fukawi1 View Post
Some things to check in sshd_config

TCPKeepAlive, ClientAliveCountMax, ClientAliveInterval.
Hii fukawi1,

Thanks for the reply

I know about these things but I want to know why this happens with only one server and not others

as I checked sshd_config of other machines as well and I don't see any changes but the only difference is they seem to work properly and never gets disconnected?
 
Old 12-30-2011, 12:12 AM   #4
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 189Reputation: 189
try tailing the secure log in one session
Code:
tail -f /var/log/secure
then start a new session and let it drop out. and check if the log has anything useful to say.

I havent used putty in years so i dont know much about it now, but as your link suggests, it may be doing something to disconnect after inactivity.. What happens if you ssh from a different linux host to the problematic one? (to isolate if it is a putty/client, or server problem.
 
Old 12-30-2011, 04:56 AM   #5
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,188
Blog Entries: 4

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by fukawi1 View Post
try tailing the secure log in one session
Code:
tail -f /var/log/secure
then start a new session and let it drop out. and check if the log has anything useful to say.

I havent used putty in years so i dont know much about it now, but as your link suggests, it may be doing something to disconnect after inactivity.. What happens if you ssh from a different linux host to the problematic one? (to isolate if it is a putty/client, or server problem.
this is the output of command you mentioned

Code:
Dec 19 21:35:28 server sshd[2741]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=10.10.10.30  user=root
Dec 19 21:35:30 server sshd[2741]: Failed password for root from 10.10.10.30 port 52162 ssh2
Dec 19 21:35:32 server sshd[2741]: Accepted password for root from 10.10.10.30 port 52162 ssh2
Dec 19 21:35:32 server sshd[2741]: pam_unix(sshd:session): session opened for user root by (uid=0)
Dec 19 21:51:05 server sshd[2741]: pam_unix(sshd:session): session closed for user root
Dec 19 21:52:10 server sshd[2799]: Accepted password for root from 10.10.10.30 port 52312 ssh2
Dec 19 21:52:10 server sshd[2799]: pam_unix(sshd:session): session opened for user root by (uid=0)
Dec 19 22:07:15 server sshd[2799]: pam_unix(sshd:session): session closed for user root
Dec 20 02:44:55 server sshd[3320]: Accepted password for root from 10.10.10.30 port 59671 ssh2
Dec 20 02:44:55 server sshd[3320]: pam_unix(sshd:session): session opened for user root by (uid=0)
and even I tried from ssh
the session gets disconnected in a while with this error message
Code:
Read from remote host 192.168.0.195: Connection reset by peer
Connection to 192.168.0.195 closed.
 
Old 12-30-2011, 05:23 AM   #6
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 189Reputation: 189
Nothing stands out to me there...
But a couple more ideas worth trying..

To get more info out of the error. try adding -vvv to the ssh command. and stopping the sshd process on the server, and running it from the commandline with debugging increased.
Code:
sshd -ddd &
adding -e will make ssd show errors on screen rather than log them, if your sitting at the screen.

Is the shell inactivity timeout set to something silly? IIRC 0, means the shell wont time out. On the ssh SERVER, run the below, it can be set permenantly in .bashrc.
Code:
echo $TMOUT
Could it be ACPI powering down a disk, or something, the delay of it powering back up causing the dropout?

Is there a firewall inbetween the client and server, that could be dropping inactive connections?

Just some food for thought anyway...
 
Old 12-30-2011, 05:39 AM   #7
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,188
Blog Entries: 4

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
I changed the
Code:
ClientAliveInterval 300

ClientAliveCountMax 5
but still same issue
I'll try your steps but today office time over so will get back on monday till then

HAPPY NEW YEAR
 
Old 01-03-2012, 11:34 PM   #8
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,188
Blog Entries: 4

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
Now I did some changes

Code:
ClientLiveInterval 60
ClientAliveCountMax 5
and now I think the ssh is not getting disconnected when kept idle

I logged in using
Code:
#ssh -vvv 192.168.0.195
and now when I leave the console idle for few minutes, this is something which I get and am unable to understand if you can throw some light on it

Code:
[root@server ~]# debug1: client_input_channel_req: channel 0 rtype keepalive@ope                                                                                        nssh.com reply 1
debug1: client_input_channel_req: channel 0 rtype keepalive@openssh.com reply 1
debug1: client_input_channel_req: channel 0 rtype keepalive@openssh.com reply 1
debug1: client_input_channel_req: channel 0 rtype keepalive@openssh.com reply 1
does it means that ssh itself is sending packets after every 1 min to keep the session alive as I have mentioned in sshd_config?

But still even if the problem is solved I don't get any answer to my question that why it happens only on one server where all other session works fine without any changes?

I also tried adding this line
Code:
ServerAliveInterval 60
but while restarting it returns with a error
Code:
Bad configuration option: ServerAliveInterval
Is it some where related to version of ssh or distribution support?
 
Old 01-03-2012, 11:47 PM   #9
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 189Reputation: 189
Quote:
Originally Posted by deep27ak View Post
does it means that ssh itself is sending packets after every 1 min to keep the session alive as I have mentioned in sshd_config?
Yes, you wont see the debug messages when ssh'ing normally (ie: without -vvv)

Quote:
But still even if the problem is solved I don't get any answer to my question that why it happens only on one server where all other session works fine without any changes?
That, I'm not sure about, what is the server doing? is it under heavy system load, or traffic load perhaps?

Quote:
Is it some where related to version of ssh or distribution support?
ServerAliveInterval, is effectively the same as ClientAliveInterval, except in the other direction, it is set in the clients ssh_config.
 
Old 01-04-2012, 12:39 AM   #10
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,188
Blog Entries: 4

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by fukawi1 View Post
That, I'm not sure about, what is the server doing? is it under heavy system load, or traffic load perhaps?

No, that is my mail server and is touched only when required to make any changes in the config file.

Do you have any possible ideas which might be the reason for such issue?
I have installed sendmail+apache+squirrelmail on this server and nothing else
But it seems while restarting ssh is unable to recognise the syntax used for ServerAliveInterval

does it has anything to be done with distro used?
 
Old 01-04-2012, 03:16 AM   #11
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 189Reputation: 189
Quote:
Originally Posted by deep27ak View Post
Do you have any possible ideas which might be the reason for such issue?
Not really, i guess there could be any number of reasons, but I cant see any obvious ones in this situation.

Quote:
But it seems while restarting ssh is unable to recognise the syntax used for ServerAliveInterval
does it has anything to be done with distro used?
As i said in my last post, ServerAliveInterval, is set in ssh_config, on the client machine.
ClientAliveInterval, is set in sshd_config, on the server.
I believe that to be the same for all distro's.
 
1 members found this post helpful.
Old 01-04-2012, 03:20 AM   #12
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,188
Blog Entries: 4

Original Poster
Rep: Reputation: 220Reputation: 220Reputation: 220
Quote:
Originally Posted by fukawi1 View Post

As i said in my last post, ServerAliveInterval, is set in ssh_config, on the client machine.
ClientAliveInterval, is set in sshd_config, on the server.
I believe that to be the same for all distro's.
oops, sorry my mistake
Yes its working when placed in ssh_config

Well, Thanks for your help
 
  


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
ssh disconnects Xris718 Linux - Software 5 07-22-2010 04:30 PM
ssh connection inactive Sunb3 Red Hat 4 07-07-2010 06:59 AM
SSH disconnects dirtybird04 Linux - Networking 2 11-04-2009 05:36 AM
ssh disconnects goldwing Linux - Networking 3 05-26-2008 09:42 AM
Mac OS X ssh client / linux sshd : ssh hangs/disconnects Apollo77 Linux - Networking 1 05-24-2006 11:53 AM


All times are GMT -5. The time now is 09:20 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration