Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm administrating a networked environment where the users authenticate over NIS. All machines can be used to SSH into the server but one. On the machine in question, I get the message

ssh: connect to host servername port 22: Connection refused

I compared strace outputs from the machine in question and a machine that can SSH into the server correctly.
It turns out the machine that can't SSH into the server doesn't consult /etc/hosts while the machine that can SSH correctly does. Both machines have /etc/hosts set up with the server's name and IP. In the end, the machine that doesn't consult /etc/hosts ends up trying to connect to 127.0.0.1 (localhost) and fails with the above message. What can be causing this?

Additional information:

  • The server I'm trying to SSH into also acts as the name server and both machines consult it while trying to SSH into it.
  • The machine that can't SSH into the server can SSH correctly into other machines when I do
    ssh machinename
    The strace logs show that the machine consults the nameserver (this time successfully) and manages to resolve the remote machine name correctly and connect to it.

EDIT: I will gladly provide any additional information that you think might help solve this issue.

share|improve this question
1  
What do you get when you add -vvv to the ssh command? –  KayakJim Nov 6 '12 at 19:26
add comment

1 Answer

up vote 13 down vote accepted

It sounds to me like the problem host does not have a correctly configured nsswitch.conf.

The hosts line of /etc/nsswitch.conf should look something like this:

hosts:  files nisplus nis dns

However, the exact contents will vary due to your environment. You should compare against working hosts and make changes accordingly.

share|improve this answer
    
Right on the money! I compared against a working host and made the required changes and that did it. Thanks a lot! I'd vote you up if I had the rep :) –  Joseph R. Nov 6 '12 at 19:59
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.