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

Reply
2 replies

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.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

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

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.