Fix: ssh client timeouts in OS X

Using OS X and getting a lot of this?

Read from remote host Connection reset by peer
Connection to closed.

So was I. At first I assumed it had to be Comcast, because Comcast falls into the auto scape goat category the same as Microsoft and the Bush Administration.

Before I became all accusatory and call and complain I did my home work.

The man page for ssh_config has the following to say.

Specifies whether the system should send TCP keepalive messages
to the other side. If they are sent, death of the connection or
crash of one of the machines will be properly noticed. However,
this means that connections will die if the route is down tempo-
rarily, and some people find it annoying.

The default is “yes” (to send TCP keepalive messages), and the
client will notice if the network goes down or the remote host
dies. This is important in scripts, and many users want it too.

To disable TCP keepalive messages, the value should be set to

Sounds like that could be the problem. Issuing the following command as root will add the directive to the bottom of the ssh_config file and you should be good to go.

echo “TCPKeepAlive no” >> /etc/ssh_config

UPDATE: At least I thought you should be good to go. After running like that for a while I still lost my connection. Does anyone else have any insight into why this may be happening? I suspect Comcast, again. 🙂

3 Replies to “Fix: ssh client timeouts in OS X”

  1. Damn I thought you might have had an answer to my issue … I am using Adelphia , keep looking 😉

  2. It almost has to be some sort of timeout issue. At work I stay connected to my servers for weeks with no problem. At home it dumps me in about 15 minutes… unless I’m tailing a file or in top or something else that keeps the connection alive by constantly sending data.

    I thought for sure that TCPKeepAlive was the problem. So weird.

  3. heh I am having the exact same issues. If I am compiling something or using top etc it will stay connected till I am blue in the face. But the momment I have it jsut sitting there it will time out after X min.

Comments are closed.