I just needed to share that, a couple of hours ago, I finally worked out why SSH was slow to connect inside my home network. This has been nagging me for… well, years, probably. It’s one of those problems that I didn’t run into too often, and it only caused about five seconds of inconvenience each time, so it never really passed the threshold of dealing with it. Except today, for some reason.

It turns out that my server (running Ubuntu 9.10) was doing a reverse DNS lookup every time, presumably out of some effort to log the domain name of the machine trying to connect to it. The forum discussion that pointed in this direction is here; below is an outline of what I did to fix it and/or should do to fix it more elegantly, in case anyone’s interested.

Short-term solution: edit /etc/ssh/sshd_config on the server and add the line:

UseDNS no

…so that it doesn’t bother with the lookup. Then restart the SSH daemon:

sudo /etc/init.d/ssh restart

Medium-term solution: add /etc/hosts entries on the server for each computer in the house. Also, get the router to assign them static IPs. (I should probably do this anyway; I’ve just been lazy about it.)

Long-term solution: find out whether my router can work as a DNS server, or, failing that, run one on the Ubuntu box.

Leave a Comment