A particular box at $work had been slow to SSH to for a while, and I finally wanted to spend the time to find out why.
Running ssh -v thatmachine showed that it was hanging whilst attempting to authenticate with GSSAPI, with the slow section looking like:
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found
debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found
debug1: Unspecified GSS failure. Minor code may provide more information
debug1: Next authentication method: publickey
debug1: Offering public key: /home/davidp/.ssh/id_rsa
# authentication by public key then proceeded quickly
SSHing to the machine by IP instead, i.e. ssh -v 10.1.1.192, produced slightly different output:
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
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
debug1: Next authentication method: publickey
# authentication by public key then succeeded quickly
It’s clear that it’s trying to authenticate using GSS-API (Kerberos), failing, then moving on to public key auth.
The fix is simple – disable attempts to use GSS-API by adding the following to ~/.ssh/config:
GSSAPIAuthentication no
Before adding that:
[davidp@columbia:~]$ time ssh 10.1.1.192 touch /dev/null | grep real
real 0m15.512s
After adding it:
[davidp@columbia:~]$ time ssh 10.1.1.192 touch /dev/null | grep real
real 0m0.611s
Problem solved.