Thursday, March 4, 2010

Slow SSH connection to remote server


When I tried to ssh connect to a new remote server, it took a longer time. Although it got connected finally. I was curious so I turned on the debug mode:
   ssh -v remote_server
The log showed that there was a pause when ssh client application was trying authentication method gssapi-with-mic. After 3 trials, ssh client tried the next authentication method and succeeded:
   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
   No credentials cache found

   debug1: Unspecified GSS failure.  Minor code may provide more information
   No credentials cache found

   debug1: Unspecified GSS failure.  Minor code may provide more information


   debug1: Next authentication method: publickey
We could skip the gssapi-with-mic authentication method and only tried publickey and password by using the PreferredAuthentications options:
   ssh -o PreferredAuthentications=publickey,keyboard-interactive remote_server
The ssh client first tried the private/public authentication method. If failed, it would prompt the user for password. There would be no long pause any more during the connection.

If you don't want to type such a long option in your command line, put it into a configuration file. Create a file ~/.ssh/config in your home directory. Inside the file, add this one line:
   PreferredAuthentications publickey,keyboard-interactive

1 comment:

Saqib said...

cool! many thanks for that tip!

 
Get This <