Well, like pretty much everyone doing web development we regularly ssh and sftp into the server to change configurations and update files.
We recently upgraded our web server we hit an issue that whenever we ran ssh (or sftp), it would take about 20 seconds for the password prompt to appear. As we are using a Unix based client (OS X), initially we thought it was a problem on this client machine but connections to all other servers were fine.
The problem appears to be that the SSH deamon (sshd) tries to do a reverse lookup of the IP address of the client machine connecting. This takes time and often fails hence the slow response.
If you look online, you’ll see people suggesting adding “GSSAPIAuthentication no” or “GSSAPIDelegateCredentials yes” or even installing updates to krb5-config.
We found the solution to be a one liner change to the /etc/ssh/sshd_config file on the server (the machine you are connecting to). Just add (or change the existing) UseDNS line to “no” like this: UseDNS no.
Save this change, then restart the sshd service:
sudo /etc/init.d/ssh restart
Now, try logging in again with ssh from your client and the response will be much better.
Another suggestion I found here: http://egopoly.com/2008/02/04/ssh-slow-on-leopard/ suggest to add SRV records to you zone files for your domains. It was easier to edit the sshd_config file so I am not sure if this would resolve the issue or not.