Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The authenticity of host can't be established

Tags:

git

ssh

I am doing a git pull for the first time and have been prompted in git that the authenticity of host can't be established, the RSA key fingerprint isn't correct compared to the private key I generated. I was just wondering how I can update this so it reads the correct file and why does it read the wrong fingerprint in the first place?

like image 612
styler Avatar asked Jul 12 '12 00:07

styler


People also ask

How do you avoid the authenticity of host Cannot be established?

The Authenticity Of Host Can't Be Established Are you sure you want to continue connecting (yes/no)? If your answer is 'yes', the SSH client continues login, and stores the host key locally in the file ~/. ssh/known_hosts . If your answer is 'no', the connection will be terminated.

What are known hosts?

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.

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

I had similar issue, which means that the remote host is unknown /untrusted. The fix is to have the remote host entry in the known_hosts file.

This is what I have done:

  1. Generate (or use existing) RSA keys and store them in the <USER.HOME>/.ssh file. If you are using eclipse, you can generate RSA keys using Preferences;

    • General -> Network Connections -> SSH2 and then select the Key Management.
    • Now Click Generate RSA Key...
    • And then Save Private Key... in the .ssh folder
  2. Now your <USER.HOME>/.ssh would contain file; private key, public key and known_hosts

  3. share your public key with your trusted hosts.
  4. Open Git Bash Promp (command prompt) and enter below command.
  5. When it prompts error ... Are you sure you want to continue connecting (yes/no)?
  6. Say 'yes'
  7. Now your remote host is added to the known_hosts
  8. Done.

Now if you try pushing the file to remote, you don't see any errors.

like image 125
vijay Avatar answered Sep 18 '22 12:09

vijay


After you add your ssh key to GitLab, when you try to clone the repository, If you press enter directly, you will get below error:

Cloning into 'hfe-insure-m'... The authenticity of host 'git.zhonganinfo.com (100.112.23.182)' can't be established. ECDSA key fingerprint is SHA256:IRLOr2bTvVB2rLgYVgyUibE+oLlZ0pUwU9wycc/5zYU. Are you sure you want to continue connecting (yes/no/[fingerprint])?  Host key verification failed. fatal: Could not read from remote repository.  Please make sure you have the correct access rights and the repository exists. 

Make sure you enter yes when you see the below sentence, DO NOT press enter directly.

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

E.g.

Cloning into 'hfe-insure-m'... The authenticity of host 'git.zhonganinfo.com (100.112.23.182)' can't be established. ECDSA key fingerprint is SHA256:IRLOr2bTvVB2rLgYVgyUibE+oLlZ0pUwU9wycc/5zYU. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'git.zhonganinfo.com,100.112.23.182' (ECDSA) to the list of known hosts. remote: Enumerating objects: 31607, done. remote: Counting objects: 100% (31607/31607), done. remote: Compressing objects: 100% (10365/10365), done. remote: Total 31607 (delta 20695), reused 31485 (delta 20604) Receiving objects: 100% (31607/31607), 21.51 MiB | 581.00 KiB/s, done. Resolving deltas: 100% (20695/20695), done. 
like image 33
slideshowp2 Avatar answered Sep 20 '22 12:09

slideshowp2