bootsz bootsz - 1 year ago 151
Git Question

Git error: "Host Key Verification Failed" when connecting to remote repository

I am trying to connect to a remote Git repository that resides on my web server and clone it to my machine.

I am using the following format for my command:

git clone ssh://

This has worked fine for most of my team members. Usually after running this command Git will prompt for the user's password, and then run the cloning. However, when running on one of my machines I get the following error:

Host key verification failed.

fatal: Could not read from remote

We are not using SSH keys to connect to this repository, so I'm not sure why Git is checking for one on this particular machine.

Answer Source

You are connecting via the SSH protocol. Using SSH, every host has a key. Clients remember the host key associated with a particular address and refuse to connect if a host key appears to change. This prevents man in the middle attacks.

The host key for has changed. If this does not seem fishy to you, you can remove the old key from your local cache using

$ ssh-keygen -R

I strongly encourage you to consider having users authenticate with keys as well. That way, ssh-agent can store key material for convenience (rather than everyone having to enter her password for each connection to the server), and passwords do not go over the network.