Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to add the host to the list of know hosts

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.

like image 754
Sasha Avatar asked Jul 16 '13 04:07

Sasha


People also ask

How do I add to list of known hosts?

To add this host key for all users of the client computer, copy the host public key file to /etc/ssh2/hostkeys. To add this host key for an individual user, copy the host public key file to ~/. ssh2/hostkeys.

How do you reset the known hosts?

Windows with PuTTYSearch for regedit.exe and open it. Navigate to HKEY_CURRENT_USER/SOFTWARE/SimonTatham/PuTTy/SshHostKeys. Right click the offending key and click delete.

What is known host in ssh?

ssh/known_hosts file contains the SSH fingerprints of machines you've logged into. These fingerprints are generated from the remote server's SSH key. When you secure shell into a remote machine for the first time, you are asked if you want to continue connecting (Figure A).

What does ssh Keyscan do?

ssh-keyscan is a command for gathering the public host keys for a number of hosts. It aids in building and verifying ssh_known_hosts files. ssh-keyscan provides a minimal interface suitable for use by shell and Perl scripts.


2 Answers

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.

like image 55
kenorb Avatar answered Sep 27 '22 02:09

kenorb


This is the solution i needed.

sudo chmod 700 ~/.ssh/ sudo chmod 600 ~/.ssh/* sudo chown -R ${USER} ~/.ssh/ sudo chgrp -R ${USER} ~/.ssh/ 
like image 25
Stoney Eagle Avatar answered Sep 27 '22 02:09

Stoney Eagle