OSX: ssh: Could not resolve hostname: nodename nor servname provided, or not known

Posted on

QUESTION :

There are two mac hosts in my Wi-Fi network (laptop and Desktop)
I’m trying to ssh laptop from Desktop – everything works fine
When I’m trying to ssh from laptop to Desktop doing this:

ssh macpro.local

I get this:

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

defining usrename@macpro.local or root@macpro.local makes no difference

But when I do this:

ssh 192.168.1.67

it works.

As I said I have no problem doing all this on my desktop.
Also when I do this (on both computers)

/usr/sbin/sshd -t

I get this:

Could not load host key: /etc/ssh_host_rsa_key
Could not load host key: /etc/ssh_host_dsa_key

Please help!

ANSWER :

Fixed adding to /etc/hosts:

192.168.1.67 macpro.local

For some reason ~/.ssh/config is not enough

This message implies that you do not have sufficient filesystem permissions for the file containing your key. Use chmod 600 to set the rights correctly.

The reason you get “Could not load host key” is probably because those files contain private keys and are protected. Try:

sudo /usr/sbin/sshd -t

As to lookups for macpro.localnot working, check sharing settings. Below the “Computer Name” field, it should tell you the name that other computers can access your desktop with. The “Edit” button lets you alter that.

I met the similar issue, I can ping my <hostname> but when I ssh it, just report can’t resolve.
I solved this problem by adding an empty line at the end of /etc/hosts!
By the way, it happened on macOS

Leave a Reply

Your email address will not be published. Required fields are marked *