A possible fix for slow SSH connections

Mar 31, '05 09:43:00AM

Contributed by: Anonymous

I noticed that while SSHing to some of my servers at work that connections where taking forever. The few severs I could actually connect to would take over two minutes to connect to before I would get a password prompt. Other servers would time out alltogether after three minutes.

Most of this activity takes place over a VPN connection to a Watchguard. I thought I might have screwed something up with all of the config changes I made, so I reinstalled OS X. After a fresh install, I could connect to all of my servers. The connections still took a long time (30 to 45 seconds) to establish, but at least I could get in. After upgrading from 10.0 to 10.3.8, the same problem came back. After some more digging, I started running SSH in three levels of debug mode (i.e. ssh -v -v -v user@192.168.0.3). I found that it would hang at the following point:

...
debug1: Remote protocol version 2.0, remote software version OpenSSH_3.8.1p1
debug1: match: OpenSSH_3.8.1p1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.6.1p1+CAN-2004-0175
debug3: Trying to reverse map address 192.168.0.3.
...
Read the rest for my solution...

At this point, I tried adding the following entry in /etc/hosts:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
192.168.0.3     sun     <---- NEW ENTRY
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost 
And now I can connect without SSH timing out on me. Issuing either ssh user@sun or ssh user@192.168.0.3 brings back an instant password prompt. I tried adding a second server to the hosts list that would usually time out, and it instantly came back with a password prompt as well.

If anyone else's SSH connections have been timing out or taking forever I hope this helps.

Comments (30)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050329185832952