Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is a situation which I noticed. I have a server to which I login via SSH and when I do it from lan then things work perfectly and I have noticed that even if the connection is idle (i.e. I am not doing any thing on SSH session just logged in) the connection is alive for a long time, but if I do an SSH on same server from internet then the connection after some time dies.The server is a Ubuntu 10.04 server edition server.What can be possible reason for this?

share|improve this question
up vote 5 down vote accepted

Enable keepalives in your ssh client, your firewall/router is killing the idle connection.

I have ServerAliveInterval 59 in ~/.ssh/config for openssh client.

share|improve this answer
Ok I do not have any such line as you mentioned since the server is in a corporate data centre is it possible for the sysadmin to detect an idle connection in this situation given the fact that to this server I am the only person who has SSH access to it. – Bond Jan 27 '11 at 7:10
Just as clarification; consumer grade hardware with little memory kills connections that haven't been active for a while. TCP keepalives can cause disconnects, so you can also, if you use something like screen or tmux, put a clock in your status bar so you have trafic all the time :) – Halfgaar Jan 27 '11 at 10:38

You could look at the TCPKeepAlive option in sshd_config on the server. It looks like if this is enabled you will see more disconnections (which seems a bit counter intuitive until you read the doc) as any route changes between you and the server will result in a disconnection. That is unlikely to happen on the LAN, but fairly likely across the internet.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.