Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an old P4 system which is running Ubuntu 11.04. The machine is connected to the internet via a USB wireless adapter, and it has openssh installed, so I can connect to it from other computers in my network. My problem is, a few minutes after I connect to the machine via ssh, the ssh connection freezes and I cannot do anything on terminal. I know that the server is still connected to the wireless network, but somehow it doesn't respond...unless I request a web page or anything else from the internet on the server machine. When ssh connection freezes, I use the server machine to request a web page using wget, it waits for a while, then downloads the page, and then the ssh connection which was frozen earlier starts to work again.

As a temporary solution, on server machine I execute a script which requests a web page (via wget) periodically. So far, it looks like this solution works fine, however I don't get why the machine is acting that way. Any ideas?

share|improve this question

1 Answer 1

You probably need to setup your SSH Keepalive to something under a minute (on your client side).

Look at /etc/ssh/ssh_config file

ServerAliveInterval
Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server.
The default is 0, indicating that these messages will not be sent to the server, or 300 if the BatchMode option is set.
This option applies to protocol version 2 only.
ProtocolKeepAlives is a Debian-specific compatibility alias for this option.

Your need to keep connection active indicates you need this.

For a better understanding, look at the OpenSSH FAQ,
Particularly, My ssh connection freezes or drops out after N minutes of inactivity.

This is usually the result of a packet filter or NAT device timing out your TCP connection due to inactivity. You can enable ClientAliveInterval in the server's sshd_config, or enable ServerAliveInterval in the client's ssh_config (the latter is available in OpenSSH 3.8 and newer).

Enabling either option and setting the interval for less than the time it takes to time out your session will ensure that the connection is kept "fresh" in the device's connection table.

You might also be interested in the TCPKeepAlive setting.
(I am not suggesting you change it; just that you read about it too)

share|improve this answer
    
I guess the problem is not related to ssh, because after some network inactivity in the server machine I can't even connect via ssh. But, again, when I request a web page on server side, ssh goes back to normal and I can connect. –  blahbaa Jun 3 '11 at 15:20

Your Answer

 
discard

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.