Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I try to connect ssh it takes too long (almost 2 minutes) to appear password prompt.

Why does this happens?

share|improve this question
The answer of Gilles should be the answer as explained in the comments, really. – gertvdijk Jan 25 at 17:47

2 Answers

There are several things that can go wrong. Add -vvv to make ssh print a detailed trace of what it's doing, and see where it's pausing.

The problem could be on the client or on the server.

A common problem on the server is if you're connecting from a client for which reverse DNS lookups time out. (A “reverse DNS lookup” means getting back from the client machine's IP address to a host name. It isn't really useful for security, only slightly helpful to diagnose breakin attempts from log entries, but the default configuration does it anyway.) To turn off reverse DNS lookups, add UseDNS no to /etc/ssh/sshd_config (you need to be root on the server).

Another thing that can go wrong is GSSAPI authentication timing out. If you don't know what that is, you're probably not relying on it; you can turn it off by adding the line GSSAPIAuthentication no to /etc/ssh/ssh_config or ~/.ssh/config (that's on the client side).

share|improve this answer
up vote -1 down vote accepted

It is something that comes wrong from Ubuntu's installation.

To fix it you have to change this line in /etc/nsswitch.conf:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

And change it for this one:

hosts:          files dns
share|improve this answer
2  
Ubuntu's configuration isn't wrong. In some cases (home networks with no central DNS servers), it's the right thing. In others (networks where mDNS requests time out), it's bad. – Gilles Jan 22 at 21:16
the [NOTFOUND=return] should not be there. – Neuquino Jan 25 at 17:47
1  
@Neuquino It should be there. It's there for a reason you don't understand, apparently. Fiddling with your nsswitch.conf like this is asking for trouble and not providing a general solution to slow SSH. – gertvdijk Jan 25 at 17:47

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.