/.ssh/known_hosts file does not exist? (Mac)

16,564

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
Share:
16,564

Related videos on Youtube

Chris
Author by

Chris

Updated on September 18, 2022

Comments

  • Chris
    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
      Admin over 12 years
      Do 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
      Doon about 12 years
      make 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
      harrymc almost 11 years
      Try 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
      Adrian almost 11 years
      @harrymc, I think you should post this as an answer, not a comment.
  • harrymc
    harrymc almost 11 years
    There 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).