PROBLEM :
An SSH connection is slow to log in. The SSH connection to the server is made immediately, the server requests a password, but the time to get the first prompt is 30+ seconds.
NOTES :
When an SSH connection is made, the sshd process does a reverse DNS lookup on the client. If one of the DNS servers you have configured in /etc/resolv.conf is down or slow to respond, the SSH authentication process will be slow. All DNS servers configured will be queried and *all* must respond.
SOLUTION :
Test each DNS server for looking up the SSH client.
# dig @<DNS SERVER> a <CLIENT IP>
# dig @<DNS SERVER> a <CLIENT HOSTNAME>
Remove any DNS server that is not responding.
An alternative solution is to edit the sshd configuration file and remove the DNS lookups during authentication.
# vi /etc/ssh/sshd_config
Find the line "#UseDNS yes" and uncomment it if necessary. Replace that line with:
UseDNS no
Save the file and restart sshd using:
# service sshd restart