Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Remove SSH connection delay UNIX
Tiger only hintAfter upgrading to Tiger, I noticed an infuriatingly long delay when trying to connect to remote hosts via SSH in Terminal.

After some poking around, I finally figured out that SSH under 10.4 is checking for IPv6 addresses as well as IPv4 addresses, and is hanging until its search times out. The solution is simple:
  1. Open up Terminal

  2. Edit the /etc/ssh_config file as root (note this is not /etc/sshd_config). Just type sudo emacs /etc/ssh_config; replace emacs with your favorite editor

  3. Add the following line to the file:
    AddressFamily inet
  4. Save and close the file. Under emacs this is done via Control-X Control-C Y
That's it! Enjoy normal SSH connections again...
    •    
  • Currently 2.83 / 5
  You rated: 3 / 5 (6 votes cast)
 
[21,103 views]  

10.4: Remove SSH connection delay | 10 comments | Create New Account
Click here to return to the '10.4: Remove SSH connection delay' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Remove SSH connection delay
Authored by: Safar on May 13, '05 12:01:44PM

thank you so much !!! i wish you this hint was posted yesterday, before i lost two hours !!



[ Reply to This | # ]
10.4: Remove SSH connection delay
Authored by: g16l on May 13, '05 12:08:09PM

If you don't like to edit /etc/ssh_config as root, put the line into ~/.ssh/config instead.



[ Reply to This | # ]
10.4: Remove SSH connection delay
Authored by: thePervertedMonk on May 13, '05 03:45:42PM

Excellent hint.

But for some users, who may not be able to comfortably edit the '/etc/ssh_config', here's a pretty nifty workaround.

If you're using your .basrc file to set config settings for your term, you can simply create an alias:

alias ssh='ssh -4'
-->the -4 forces ssh to only try to connect using IPv4

Another handy technique, I also use is the '-v' switch whenever I'm connecting to a remote host.
-->the -v turns on verbose mode, and print any ssh client/server msgs to the screen, so you know exactly what's up. Perfect for debugging trouble-some connections.

That alias now becomes: alias ssh='ssh -4 -v', so whenever you invoke the ssh command from the cli, 'ssh -4 -v' is actually sent, and all you have to do is specify your other connection options.

I use a creative mix: /etc/ssh_config, ~/.ssh/config and my .bashrc, to get it just right. Plus I find it keeps things in the correct order, as ssh actually reads prefs in that order, anyway.

Hope this can help someone.

---
/the Perverted Monk
"my rant is my giant exhale... my exasperation at this approximation
of civilization that causes mad denigration in multiple nations"



[ Reply to This | # ]
10.4: Remove SSH connection delay
Authored by: thePervertedMonk on May 13, '05 03:53:29PM

Small Clarification
---------------------

SSH prefs are read in this order;
CL options--> user options --> system options.

---
/the Perverted Monk
"my rant is my giant exhale... my exasperation at this approximation
of civilization that causes mad denigration in multiple nations"



[ Reply to This | # ]
10.4: Remove SSH connection delay
Authored by: auricgoldfinger on May 13, '05 12:58:48PM

So THAT's the reason! Even the ssh connections to the computer directly connected to my powerbook was suddenly that slow!
Great, thanks!!!



[ Reply to This | # ]
10.4: Remove SSH connection delay
Authored by: hgd on May 15, '05 06:57:11AM

Just FYI: this is only a problem if your DNS is broken and doesn't answer to AAAA record requests. Unfortunately most DNS servers in cheap (WLAN) routers *are* broken! Still, this isn't Apple's fault ...



[ Reply to This | # ]
10.4: Remove SSH connection delay
Authored by: currawong on May 31, '05 09:53:54PM

You can also do this on the command line with individual connections:

ssh -o AddressFamily="inet" -l loginname host.domain.com

In my .tcshrc file (I use tcsh not bash, so this wont be the same for everyone) I alias commonly used connections this way:

alias myserver "ssh -o AddressFamily="inet" -l loginname myserver.com"

Makes life much easier.



[ Reply to This | # ]
10.4: Remove SSH connection delay
Authored by: hulmer on Apr 19, '06 01:38:30PM

Running 2 macs: 1 running 10.3, the other 10.4. I can ssh from 10.3 to 10.4 without a problem. However, I get the long delay when ssh'ing 10.4 to 10.3.

Tried adding "AddressFamily inet" to /etc/ssh_config as suggested, but didn't fix the problem. Confident it's not a dns issue cause I'm ssh'ing to the IP of the 10.3 box. When i run -v switch, it sits for about 13 seconds at:

"debug1: SSH2_MSG_SERVICE_ACCEPT received"

Any other suggestions to try?



[ Reply to This | # ]
10.4: Remove SSH connection delay
Authored by: regulus on Apr 20, '06 12:01:06AM

This didn't work for me either. The only fix that's worked for me was to add the computer I'm trying to connect to into the /etc/hosts file. I added the following line at the beginning of my hosts file...

192.168.1.201 g4

then I can connect with either of the following commands...

ssh loginname@g4
ssh loginname@192.168.1.201



[ Reply to This | # ]
10.4: Remove SSH connection delay
Authored by: maestric on Jul 06, '07 01:13:27PM
Add this line to /etc/ssh_config:
GSSAPIKeyExchange no
That's it ! (It's yes by default).
I figured this out by comparing the ssh_config file to a Linux ssh_config file.

[ Reply to This | # ]