I'd love for one of you smart and helpful folks to post a list of common causes of delays during an ssh login. Specifically, there are 2 spots where I see a range from instantaneous to multi-second delays.

  1. Between issuing the ssh command and getting a login prompt and
  2. between entering the passphrase and having the shell load

Now, specifically I'm looking at ssh details only here. Obviously network latency, speed of the hardware and OSes involved, complex login scripts, etc can cause delays. For context I ssh to a vast multitude of linux distributions and some Solaris hosts using mostly Ubuntu, CentOS, and MacOS X as my client systems. Almost all of the time, the ssh server configuration is unchanged from the OS's default settings.

What ssh server configurations should I be interested in? Are there OS/kernel parameters that can be tuned? Login shell tricks? Etc?

link|improve this question
feedback

7 Answers

up vote 7 down vote accepted

Try setting UseDNS to no in /etc/sshd_config

link|improve this answer
2  
+1 that is the most common cause of delay when logging in to ssh – mugen kenichi Jul 22 '10 at 9:22
"Solaris 11 note: I tried the UseDNS no setting on Solaris 11 and it corrupted the service start. Not exactly a friendly response by the service. YMMV with other *Nix variants but it seems UseDNS no may not be a valid option in Solaris 11." - comment by Keith Hoffman – Sathya Jan 11 at 7:21
feedback

You can always start ssh with the -v option which displays what is being done at the moment.

$ ssh -v you@host

With the information you gave I can only suggest some client side configurations:

  • Since you write that you are entering passwords manually, I would suggest that you use public key authentification if possible. This removes you as a speed bottleneck.

  • You could also disable X-forwarding with -x and authentication forwarding with -a (these might already be disabled by default). Especially disabling X-forwarding can give you a big speed improvement if your client needs to start an X-server for the ssh command (e.g. under OS X).

Everything else really depends on what kinds of delays you experience where and when.

link|improve this answer
Good hint about verbosity, you can also increase it by having more v's. Up to 3 IIRC. – vtest Sep 22 '10 at 18:51
feedback

Besides the DNS issues already mentioned, if you're ssh'ing into a server with many NFS mounts, then there can be a delay between password and prompt as the quota command checks for your usage/quota on all filesystems not mounted with the noquota. On Solaris systems, you can see this in the default /etc/profile and skip it by running touch $HOME/.hushlogin .

link|improve this answer
feedback

When I ran ssh -vvv on a server with a similar slow performance I saw a hang here:

debug1: Next authentication method: gssapi-with-mic

By editing /etc/ssh/ssh_config and commenting out that authentication method I got the login performance back to normal. Here's what I have in my /etc/ssh/ssh_config

GSSAPIAuthentication no

You can make this globally on the server, so it doesn't accept GSSAPI to authenticate. Just add "GSSAPIAuthentication no" on /etc/ssh/sshd_config on the server and restart the service.

link|improve this answer
feedback

are you using local accounts ? - sometimes i find pam authentication can add a delay to logging in with ssh

link|improve this answer
Usually local accounts. Sometimes NIS. – Peter Lyons Jul 24 '10 at 2:39
feedback

Worth having a look at here: OpenSSH Slow: Hanging at SSH2_MSG_SERVICE_ACCEPT received.

link|improve this answer
feedback

Work fine.

# uname -a
SunOS oi-san-01 5.11 oi_151a3 i86pc i386 i86pc Solaris
# ssh -V
Sun_SSH_1.5, SSH protocols 1.5/2.0, OpenSSL 0x009080ff
# echo "GSSAPIAuthentication no" >> /etc/ssh/sshd_config
# svcadm restart ssh

UseDNS no do not work with OpenIndiana !!!

Read "man sshd_config" for all the options

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.