It is one of those small, yet very annoying problems. If you experience long login times with ssh – simply check the following two things in your sshd_config file (on the destination machine):

  • whether the UseDNS option is set to yes or no, after sshd_config manual: Specifies whether sshd(8) should look up the remote host name and check that the resolved host name for the remote IP address maps back to the very same IP address. The default is “yes”. You should set it to “no” in case your DNS isn’t configured to support that option
  • whether GSSAPI support is enabled; the option is called GSSAPIAuthentication and by default it’s set to yes. Again – if you are not using GSSAPI – make sure you set it to no. That will save you those annoying seconds on each login

Do not forget to restart the sshd daemon after you modify the configuration file. Remember also, that ssh can be easily debugged when you connect to a remote host by using the -v option – this way you can easily see what is happening with the connection. This is exactly how I found out what was taking so long time when connecting to a freshly installed CentOS 6.4 box.