This entry is about how I was able to fix SSH connections on my Mac OSX 10.4 from hanging at login. If non of this makes sense to you other than “Mac”, then you probably don’t need it. But since I had a hard time finding the solution, I figure I will write it down and let google try to pick it up for anyone else in search of a solution. Long story short, add records to your /etc/hosts file and SSH won’t waste time trying to resolve IP addresses. And go…
So yes, when I would attempt to SSH into ANY server from home, SSH would hang for a minute or so before giving me a password prompt. I thought this was an issue with my USI Wireless since it seemed to start around the same time and I didn’t have this problem at the coffee shop. I asked USI Wireless about it once and they said it was probably someone’s router screwing with the signal as it hopped from access point to access point in their infrastructure and they couldn’t really do anything about it. So I lived with it for months. While my laptop was broken, I borrowed my brother’s laptop which ran OSX 10.5 and the problem didn’t exist, so I thought it was fixed. Now that I have mine back, the problem continued. So I figured it wasn’t totally USI’s fault. I decided to investigate.
Firstly, I ran SSH with verbose mode on:
ssh -v silk.dreamhost.com -l myuser
This produced:
debug1: Connecting to silk.dreamhost.com [208.113.160.21] port 22. debug1: Connection established. debug1: identity file /Users/blainegarrett/.ssh/identity type -1 debug1: identity file /Users/blainegarrett/.ssh/id_rsa type -1 debug1: identity file /Users/blainegarrett/.ssh/id_dsa type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3p2 Debian-9etch2 debug1: match: OpenSSH_4.3p2 Debian-9etch2 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_4.7 ... * it hangs here ... debug1: Miscellaneous failure No credentials cache found ... * it also hangs here but eventually resolves ...
I googled a bunch for “No credentials cache found”. It seems to be a generic error since for some they were never able to connect and others had this issue after authenticating. However, I found something that said to set your CheckHostIP=no in the confs. This did nothing for me other than waste time. But it seemed to make sense based on what the USI Wireless guy was suggesting the issue was.
Finally, I found this article which changed a few other SSH settings and in the end edited the /etc/hosts file. Sherblam. That worked. Just follow the format in that file. You will probably need to run sudo to be able to write to it.
sudo pico /etc/hosts
It should be noted that this is not a Mac specific problem since Mac OSX uses Unix which in turns incorporates the OpenSSH libraries. I found out mine was running OpenSSH_4.3p2
Links:
- “ssh takes exactly 1 minute 20 seconds or 80 seconds” — forum post with similar issue
- “Mac Tiger/SSH issue” — live journal post with similar issue