ragusanus

Q: ssh cannot resolve host name (but host, ping and nslookup can)

I have recently upgraded from Snow Leopard (10.6.8) to  El Capitan (10.11.6)

and the following problem has been present under both OSX versions.

 

ssh is unable to resolve ONE PARTICULAR host name:

 

$ ssh myserver1.mylab.mydomain

nc: getaddrinfo: nodename nor servname provided, or not known

ssh_exchange_identification: Connection closed by remote host

 

On the other side, host, ping and nslookup are able to resolve the

name of this host correctly.


Using the IP address for that host, I am able to access it with ssh.

 

The weird thing is that ssh has this problem only for this one particular

host. If I try to ssh to other nodes in the same domain or anywhere

else, I have no problem logging in with the host name.


Other programs using ssh (Transmit, x2go) have the same problem,

I have to use the IP address to be able to access this host.


I have tried after browsing a bit for similar problems to flush the DNS cache using:

 

$ sudo dscacheutil -flushcache

$ sudo killall -HUP mDNSResponder

 

But it did not help. As only one particular host is affected, I guess the

wrong information must be stored somewhere and needs to be deleted,

but I don't manage to find where.

 

Any suggestion will be most welcome.




MacBook Pro, OS X El Capitan (10.11.6)

Posted on Aug 20, 2016 2:53 AM

Close

Q: ssh cannot resolve host name (but host, ping and nslookup can)

  • All replies
  • Helpful answers

  • by Barney-15E,

    Barney-15E Barney-15E Aug 20, 2016 6:42 AM in response to ragusanus
    Level 9 (50,072 points)
    Mac OS X
    Aug 20, 2016 6:42 AM in response to ragusanus

    I can't solve the underlying problem, but you might be able to work around the issue by adding the entry to your /etc/hosts file.

  • by BobHarris,

    BobHarris BobHarris Aug 20, 2016 8:26 AM in response to ragusanus
    Level 6 (19,410 points)
    Mac OS X
    Aug 20, 2016 8:26 AM in response to ragusanus

    When I try to access a host name that is not resolved via DNS, I get

    ssh fred.local

    ssh: Could not resolve hostname fred.local: nodename nor servname provided, or not known

     

    But you seem to be getting

    $ ssh myserver1.mylab.mydomain

    nc: getaddrinfo: nodename nor servname provided, or not known

    ssh_exchange_identification: Connection closed by remote host

    When I get "ssh_exchange_identification: Connection closed by remote host", it generally means I was actually talking to the remove sshd.

     

    Do you get more information if you use

    ssh -v -v -v myserver1.mylab.mydomain

     

    If you get more information, I would suggest comparing that against a connection that actually works and see where the good and the bad ssh -v -v -v output starts to differ.  That can help with diagnosing ssh connections.

     

    Side NOTE: El Capitan gave me problems with AIX because of differences in encryption methods allowed.  AIX used older methods, and El Capitan was using newer methods, and not accepting the AIX methods.  I had to mess with my ssh_config file Ciphers.

     

    I ONLY mention this in case myserver1 is another Unix system that maybe has older ssh implimentation.