If you’re experiencing slow logins via SSH on a Red Hat Enterprise 6 or CentOS 6 system, it’s probably caused by DNS that is taking too long to respond. Even with correct nameservers in /etc/resolv.conf, you may still find yourself stuck with slow logins.
It’s a known issue on the Red Hat knowledgebase article DOC-58626, but since it’s closed without login, I’ll share the solution as well.
The resolver uses the same socket for the A and AAAA requests. Some hardware mistakenly only sends back one reply. When that happens the client sytem will sit and wait for the second reply. Turning this option on changes this behavior so that if two requests from the same port are not handled correctly it will close the socket and open a new one before sending the second request.
The solution is to add the following line to your /etc/resolv.conf. Just add it all the way at the bottom, as the last line.
options single-request-reopen
That should fix your slow SSH logins, given you have valid and fast-responding nameservers in your /etc/resolv.conf.