/.ssh/known_hosts file does not exist? (Mac)
The article Failed to add the host to the list of known hosts has this advice :
Check directory permissions
The ssh client needs to be able to write to files in the .ssh directory :
ls -ld ~/.ssh
If the permissions aren't correct then run this to fix them:
chmod 0700 ~/.ssh
Check file permissions
Check if the files in the .ssh directory have read-write permissions :
ls -l ~/.ssh
If they don't, run :
chmod 0600 ~/.ssh/*
Remove ACL flags
If the ssh client still cannot write to the folder, one needs to clear the ACL flags :
chmod -R -a# 0 ~/.ssh
Related videos on Youtube
Chris
Updated on September 18, 2022Comments
-
Chris over 1 year
I am trying to connect to a server via SSH in Terminal. I am able to connect to the server but during the process it asks me
"Are you sure you want to continue connecting (yes/no)?"
I type
"yes"
I then get a message that says
"Failed to add the host to the list of known hosts (User/username/.ssh/known_hosts)"
After that I tried to open and clean out the known_hosts file, but I get a message that says
"The file /Users/username/.ssh/known_hosts does not exist."
Do I need to create the known_hosts file? I thought this would happen automatically when I connected to the server?
-
Admin over 12 yearsDo you have the .ssh directory, with the correct permissions? Have you tried creating the .ssh directory if needed, and an empty known_hosts file?
-
Doon about 12 yearsmake sure that ~/.ssh exists, is a directory, is owned by your user, and has the correct permissions (700). My guess is that .ssh doesn't exist.
-
harrymc almost 11 yearsTry to follow the advice in the article Failed to add the host to the list of known hosts and let us know what happens.
-
Adrian almost 11 years@harrymc, I think you should post this as an answer, not a comment.
-
-
harrymc almost 11 yearsThere might be differences between your chmod and the one used in the article. Look in your chmod man page, section "ACL MANIPULATION OPTIONS", for ACL removal options (or for allowing all).