Just the other day, after setting up a new home linux server, I noticed that SSH login was very slow on the said server from remote desktops or notebooks. Well, I experienced this before and found out back then that one way to resolve this was to add the IP addresses of the remote PCs/notebooks that would connect to the server under /etc/hosts. This is due to the fact that the SSH server tries to do some sort of DNS lookups for remote logins and not finding the records it needs would make things slow. So I tried this out hoping it would fix things, but to my surprise SSH login was still way too slow.
After digging into the configuration and testing things out, the issue here is that SSH tries to connect to the DNS servers under the /etc/resolv.conf file to do DNS lookups and bypasses the /etc/hosts file even though you configure your server to look under hosts file first before going straight into the DNS servers. Well, looking at the SSH daemon config, you just have to set this parameter to prevent this situation from happening:
UserDNS No
After setting this up, I’m back to the speedy SSH login and learned a new thing on SSH daemon configuration. 