Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just installed Ubuntu 11.10, and whenever I try to SSH into my servers it's very slow. Before it displays the password prompt, it can take between 40 seconds and 60 seconds.

I use:

ssh myuser@myserver.com

Once I'm logged in, everything is fine and it works fast.

Why does it take so long, and how can i fix it? Are there any options in the SSH command I can use?

share|improve this question
add comment

2 Answers

up vote 25 down vote accepted

This is slow because the OpenSSH daemon uses DNS to run a reverse lookup on the client hostname to make sure it's valid

sudo vi /etc/ssh/ssh_config

Comment out the following lines

#GSSAPIAuthentication yes
#GSSAPIDelegateCredentials no

OR

add this:

UseDNS no
share|improve this answer
    
it works thanks –  joel Nov 19 '11 at 23:02
1  
you are very welcome –  Book Of Zeus Nov 19 '11 at 23:03
add comment

This is just a complement of the answer of Book Of Zeus. In case you don't have root access (sudo), you can still configure it.

You need to edit your "user ssh_config" file which is:

vi $HOME/.ssh/config

(Note: you would have to create the directory $HOME/.ssh if it does not exist)

And add:

Host *
  GSSAPIAuthentication no
  GSSAPIDelegateCredentials yes

You can do so on a per host basis if required :) example:

Host linux-srv
  HostName 192.158.1.1
  GSSAPIAuthentication no
  GSSAPIDelegateCredentials yes

Make sure the IP address match your server IP. One cool advantage is that now ssh will provide autocomplete for this server. So you can type ssh lin + Tab and it should autocomplete to ssh linux-srv.

You can add a bunch of usefull options so that you don't have to type them each time:

User <a user>
Port <a port number>
IdentityFile <a specific private key>
Compression yes
....

So instead of typing ssh -C -p 1022 -i ~/.hidden/prv-key-4096bit superuser@192.158.1.1 a simple ssh linux-srv would suffice!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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