Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I deleted the known_hosts file from .ssh folder and I can't pull or push in BitBucket repositories

I made a mistake and deleted the "known_hosts" file in ".ssh" folder! Now I can't pull or push in BitBucket repositories.

How can I solve it?

like image 612
Idemax Avatar asked Mar 20 '13 21:03

Idemax


People also ask

Can I delete known_hosts file ssh?

Windows with PuTTYNavigate to HKEY_CURRENT_USER/SOFTWARE/SimonTatham/PuTTy/SshHostKeys. Right click the offending key and click delete.

What is known_hosts in .ssh folder?

Definition(s): A file associated with a specific account that contains one or more host keys. Each host key is associated with an SSH server address (IP or hostname) so that the server can be authenticated when a connection is initiated.

Can I delete known_hosts file in Linux?

ssh/known_hosts or notepad ~/. ssh/known_hosts ), simply delete the complete line which has the reference to the host you want to remove and save the file.

What is the difference between known_hosts and Authorized_keys?

authorized_keys is a file that allows you to add ssh public keys of users that should be allowed to log into your server (the server in which the authorized_keys file lives) using key based auth. known_hosts is a file that contains a list of keys from... known hosts that you have logged into.


1 Answers

Try executing:

ssh -T [email protected]

It would give you a message somethign like:

The authenticity of host 'bitbucket.org (207.223.240.181)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)? yes

Say yes after verifying the host fingerprint (see details in the end).

Then you should get this warning, which you can ignore safely:

Warning: Permanently added 'bitbucket.org,207.223.240.181' (RSA) to the list of known hosts.
conq: logged in as tuxdude.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

Try running the git pull or git push once again and it should work this time.

NOTE: I assume you still have your .ssh/id_rsa file safely which is your private key for SSH authentication.

Verifying Host Fingerprint

As @Pascal_dher pointed out, you can be a victim of man-in-the-middle attack if you do not verify the host's fingerprint (using some out of band approach that you can rely on). For bitbucket, the info is available here.

like image 167
Tuxdude Avatar answered Oct 01 '22 01:10

Tuxdude