10

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 [email protected] or [email protected] 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!

5 Answers 5

7

Fixed adding to /etc/hosts:

192.168.1.67 macpro.local

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

4

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.

3
  • thank you, I've already found this out... Kinda fixed my ssh connection (deleting all the keys and generating them from scrach), BUT when doing /usr/sbin/sshd -t still get this: Could not load host key: /etc/ssh_host_rsa_key Could not load host key: /etc/ssh_host_dsa_key interesting, that when I do sudo /usr/sbin/sshd -t I don't get any warnings... Could you explain why? And should I fix anything?
    – drew1kun
    Commented Feb 19, 2015 at 22:27
  • The system prevents you for starting sshd as standard user and using the systemwide hostkey. This is the reason why you did not get the message when using sudo. Sudo execute the followed command with admin rights. Then the sshd is able to use the hostkey from /etc.
    – ryder
    Commented Feb 20, 2015 at 9:03
  • 1
    I understand all this, but you didn't answer why and how to fix it. In fact I can ssh now as a standart user although I still have this messages...
    – drew1kun
    Commented Feb 21, 2015 at 2:13
4

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

1
  • I can't believe this just worked... I am astonished. Thank you! Even though I have no idea WHY it worked :D
    – MarioVilas
    Commented Mar 15 at 17:30
2

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.

1
  • well on the desktop sudo /usr/sbin/sshd -t gives the same result, but on laptop I get that nice msg:@ WARNING: UNPROTECTED PRIVATE KEY FILE! @ What should I do with it??? And as to sharing settings - all is correct and should work, but it doesn't
    – drew1kun
    Commented Feb 19, 2015 at 2:45
0

Personally, I had an issue with my ~/.ssh/config file. I had to remove the host which was the host of my remote machine. I just had to keep my ~/.ssh/config as

Host *
ServerAliveInterval 300
ServerAliveCountMax 22

You must log in to answer this question.

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