Thanks to a hard drive failure, I recently installed a fresh copy of Mac OS X 10.5 (Leopard) on my MacBook. I do a lot of work on remote systems and SSH is my bread and butter. Whenever I tried to SSH into other Macs on my local network, SSH would start up but take a minute or two to connect. This problem did not occur when connecting to hosts not on the local network.
When I fired up SSH with the verbosity cranked up, here is what I saw:
$ slogin -vvv Skadi.local OpenSSH_5.1p1, OpenSSL 0.9.7l 28 Sep 2006 debug1: Reading configuration data /etc/ssh_config debug2: ssh_connect: needpriv 0 debug1: Connecting to Skadi.local [fe80::214:51ff:fe28:e74e%en1] port 22.
As you can see, my laptop is trying to connect to the remote server using IPv6. The other side of the connection is listening for SSH connections via IPv6, but something is causing the connection to timeout and failover to IPv4.
$ netstat -an | grep 22 tcp4 0 0 *.22 *.* LISTEN tcp6 0 0 *.22 *.* LISTEN
I checked the firewall settings on the remote hosts and there is nothing blocking the incoming connection. Additionally, the other Macs on my local network are connecting via IPv6.
In the end, I removed the problem by disabling IPv6 on the laptop. This is by no means a perfect solution and doesn't explain the problem at all. I'm curious if the remote hosts have some sort of cached information about the host I've reinstalled. I can't find any evidence of that, but I can't rule that out. If you have an idea I haven't thought of, please leave a comment below and let me know.