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'm currently trying to ssh to a colo, after 1 to 2 minutes of inactivity, I get:

superuser@thecolo:~$ Connection to 10.123.45.67 closed by remote host.
Connection to 10.123.45.67 closed.
mylocalmac:~ superuser$

As long as I am typing something in the ssh terminal, the connection is kept. As soon as 1 to 2 min of inactivity has happened, I will get the above message. The machine I'm trying to connect to is a Ubuntu 12.04.1 LTS 64 bit server edition. It's not a physical server but a guest VMware. I'm sshing from a mac terminal.

Please don't confuse this question with similar ones on this site with the keyword ssh_exchange_identification in it, it's unrelated.

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

Add the following to your .ssh/config and all your ssh connections will send a KeepAlive every 30 seconds:

KeepAlive yes
ServerAliveInterval 30
share|improve this answer
add comment

If you are connecting from a Linux computer you can use some options directly from the command line

TCPKeepAlive: This uses the KEEPALIVE option of the TCP/IP protocol to keep a connection alive after a specified interval of inactivity. On most systems, this means 2 hours. So, with the TCPKeepAlive option passed to SSH, the SSH client will send an encrypted packet to the SSH server, keeping your TCP connection up and running.

ssh -o TCPKeepAlive=yes user@some.host.com

ServerAliveInterval: This sets a timeout interval in seconds, which is specified by you, from which if no packets are sent from the SSH client to the SSH server, SSH will send an encrypted request to the server for a TCP response. To make that request every 30 seconds:

ssh -o ServerAliveInterval=30 user@some.host.com

Source

share|improve this answer
add comment

You need to "keepalive"

Depending on your client, this maybe trivial or just easy - it shouldn't be any harder!

For example, in putty it's on the connection option (set keepalive to a non-zero value)

share|improve this answer
    
Where do I set the keepalive? On the server or from my mac? Where should I set that value and what's the recommended value? –  Thierry Lam Dec 20 '12 at 15:51
    
Keepalive will be on the client... in your case, your Mac. There will be an option somewhere! –  Andrew Dec 20 '12 at 15:57
add comment

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.