I’ve setup several CentOS 6 virtual machines recently and they all have the same delayed SSH login problem. I’ve found a solution to this problem and I’m documenting it here so I can find it next time!
I originally found this fix at http://www.walkernews.net/2009/04/06/how-to-fix-scp-and-ssh-login-prompt-is-very-slow-in-linux/ and it’s not specific to CentOS 6, but I’ve only observed this delay problem on CentOS 6.
Now, on to the problem. SSH logins to these CentOS 6 servers were
delayed by about 30 seconds. (I never timed it exactly, but it was long
enough to be very frustrating when you’re trying to get work done) When
logging in using ssh -vvv user@hostname the debug output shows the delay
happens at these lines:
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: An invalid name was supplied
Cannot determine realm for numeric host address
debug1: An invalid name was supplied
Cannot determine realm for numeric host address
debug1: An invalid name was supplied
The solution appears to be disabling the GSS API authentication method on the SSH server.
To disable GSS API, first open/etc/ssh/sshd_config in your favorite editor
vim /etc/ssh/sshd_config
Then find the line that says
GSSAPIAuthentication yes
Change it to
GSSAPIAuthentication no
and save the file. Finally, restart the sshd service.
service sshd restart
SSH logins should now be quick as usual!