17

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.

1
  • 1
    What do you get when you add -vvv to the ssh command? Nov 6, 2012 at 19:26

1 Answer 1

21

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.

2
  • 1
    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, 2012 at 19:59
  • @JosephR. You sure have the rep now! :-) May 26, 2016 at 10:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .