Как перевести программы в режим сна на пк windows 10

Home / Failed to add the host to the list of known hosts

I recently reinstalled the operating system on my MacBookPro and discovered when trying to SSH into a new server for the first time I was getting the error «Failed to add the host to the list of known hosts (/Users/chris/.ssh/known_hosts).» This post shows what I needed to do to fix them problem.

Check directory permissions

The ~/.ssh/known_hosts file contains a list of known hosts and their public keys. If the host’s public key changes compared with what’s in the file, you are alerted when you attempt to connect that it has changed. There may be perfectly benign reasons for the change, but it may also be a security issue.

The ssh client needs to be able to write to files in the .ssh directory, so the first check is to have a look at your your .ssh directory and the files in that directory.

ls -ld ~/.ssh

will output something like this:

drwx------@ 12 chris  staff  408 12 Nov 13:51 /Users/chris/.ssh/

«chris» should be your username and «staff» the group you belong to. d indicates it’s a directory and rwx are the permissions for the user, which in this case shows we can read and write files in the directory.

If the permissions aren’t correct then run this to fix them:

chmod 0700 ~/.ssh

Check file permissions

Now check the files in the .ssh directory:

ls -l ~/.ssh

will output something like this:

-rw-------@ 1 chris  staff   1675 10 Jun  2011 id_rsa
-rw-r--r--@ 1 chris  staff    392 10 Jun  2011 id_rsa.pub
-rw-------@ 1 chris  staff  39943 12 Nov 13:51 known_hosts

As with the above, the rw flag in the user part of the file permissions shows we can read and write files. To fix the permissions if they are not correct, run this to change permissions for all of them:

chmod 0600 ~/.ssh/*

or this to just change permissions for e.g. known_hosts:

chmod 0600 ~/.ssh/known_hosts

Remove ACL flags

In my case, the permissions were all set correctly but I could write to any files or the directory itself using the ssh client, or even using a text editor. It turned out there was an ACL permission issue so I needed to clear the ACL flags to be able to write to the files again.

Run this command to recursively remove the ACL flags from under the .ssh directory:

chmod -R -a# 0 ~/.ssh

Note that if there aren’t any ACL flags on some of the files, you’ll see an error like this «chmod: No ACL present ‘.ssh’» which is OK; there’s just nothing to remove on that particular file.

I was able to now write to the files after clearing the ACL flags; always check if it’s just a file permissions issue first and try to rely on resetting ACLs as a last resort.

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

ssh root@10.109.61.119
The authenticity of host ‘10.109.61.119 (10.109.61.119)’ can’t be established.
RSA key fingerprint is 32:d7:ea:8b:7f:ff:dc:a3:db:05:93:b7:38:cc:a2:0d.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/linuxsysad/.ssh/known_hosts).

________________________________________________________________

It happened to me simply because of broken permissions. My user did not have read nor write access to that file. Fixing permissions fixed the problem.

Run Following command

chmod u+w ~/.ssh/known_host

OR

sudo chown -v $USER ~/.ssh/known_hosts

________________________________________________________________

“Technology is best when it brings people together.”

The first mistake you encounter might be

    Macintosh:Permissions 0755 for '/User/xxxx/.ssh/id_rsa' are too open.
    Linux:Permissions 0755 for '/home/xxxx/.ssh/id_rsa' are too open.

This means that your private key permissions are too large, so only you need to operate

    sudo chmod 600 ~/.ssh/id_rsa sudo chmod 600 ~/.ssh/id_rsa.pub

The known_hosts file has a problem with permissions when you encounter the following situation

    Are you sure you want to continue connecting (yes/no)?yes Failed to add the host to the list of known hosts

Execute this command

    sudo chmod 644 ~/.ssh/known_hosts

Finally, to get your.ssh folder permissions right, execute the following command

    sudo chmod 755 ~/.ssh

Then your.ssh folder and the private and public key permissions within it are resolved!

Read More:

This is the solution i needed.

sudo chmod 700 ~/.ssh/
sudo chmod 600 ~/.ssh/*
sudo chown -R ${USER} ~/.ssh/
sudo chgrp -R ${USER} ~/.ssh/

In your specific case, your known_hosts is a folder, so you need to remove it first.

For other people which experiencing similar issue, please check the right permission to your ~/ssh/known_hosts as it may be owned by different user (e.g. root). So you may try to run:

sudo chown -v $USER ~/.ssh/known_hosts

to fix it.

Tags:

Permissions

Terminal

Ssh

Github

Ssh Keys

Related

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Установить google chrome для windows 10 с официального сайта бесплатно
  • Windows на платформе linux
  • Dolby atmos for headphones windows 10 активация
  • Windows spotlight windows 10 not working
  • Клавиатура аналог apple для windows