How to Fix Failed to add the host to the list of known hosts

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: