Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Feb 27 '12 at 2:50

This question came from our site for professional and enthusiast programmers.

4  
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? –  bneely Feb 24 '12 at 16:18
2  
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. –  Doon Feb 27 '12 at 3:07
    
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. –  harrymc Jun 21 '13 at 21:58
    
@harrymc, I think you should post this as an answer, not a comment. –  Adrian Jun 24 '13 at 20:13

2 Answers 2

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|improve this answer
    
Thanks for your answer. I can do all commands you suggested except the last one, it says chmod: invalid mode: `-a#'. Besides, the error still persisted... –  Y Wang Jun 27 '13 at 21:56
    
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). –  harrymc Jun 28 '13 at 5:33

from su root

check the disc is not read only by setting it read write first:

    mount -o remount,rw /

then connect to a server via SSH in Terminal, accept key by typing yes.

remember to reset back to read only:

    mount -o remount,ro /

check status of read write:

    touch afile && { rm afile; echo "read-write"; } || echo "read-only"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.