Failed to add the host to the list of know hosts

Sasha picture Sasha · Jul 16, 2013 · Viewed 139.8k times · Source

Mac OSX Lion 10.7.

In an effort to get around weird environment stuff (homebrew wasn't installing wget, and I had all sorts of weird blocks and errors), I uninstalled zschrc and homebrew and a bunch of other stuff, then installed fish shell.

Now, whenever I try to push/pull to/from github, I get this error:

The authenticity of host 'github.com (204.232.175.90)' can't be established.
RSA key fingerprint is <string of colon-separated chars that I should probs keep private>.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/Users/sasha/.ssh/known_hosts).

So I tried to check the permissions of my ~./ssh folder, and got this, which looks fine to me:

-rw-r--r--  1 sasha  staff    97B Jul  9 22:56 config
-rw-------  1 sasha  staff   1.7K May 16  2012 id_rsa
-rw-r--r--  1 sasha  staff   403B May 16  2012 id_rsa.pub
drwx------  5 sasha  staff   170B Jul 15 09:56 known_hosts

All that's in known_hosts is a pem file I used for ssh'ing (also with the "authenticity..." prompt) to an Amazon ec2 instance, though I tried copying id_rsa and id_rsa.pub there when things got desperate.

Any idea what's going on? I'd love to fix this so I don't get prompted all the many times I push/pull.

EDIT I followed these instructions successfully a while ago, so I do have my ssh keys on Github, and they're recognized, so that when I run ssh -T [email protected], I get

Hi sashafklein! You've successfully authenticated, but GitHub does not provide shell access.

It seems to be exclusively my local computer that's unhappy with my ssh situation.

Answer

kenorb picture kenorb · Apr 29, 2014

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.