Git error when connecting to remote repository: "Host key verification failed"
P粉668113768
2023-08-27 12:34:09
<p>I'm trying to connect to a remote Git repository that resides on my web server and clone it to my computer. </p>
<p>My command uses the following format: </p>
<pre class="brush:php;toolbar:false;">git clone ssh://username@domain.example/repository.git</pre>
<p>This works well for most of my team members. Normally after running this command, Git will prompt for the user password and then run the clone. However, when running on one of my machines, I get the following error: </p>
<blockquote>
<p>Host key verification failed. </p>
<p>FATAL: Unable to read from remote
repository. </p>
</blockquote>
<p>We are not using an SSH key to connect to this repository, so I'm not sure why Git is checking for the key on this particular machine. </p>
As I did previously in cloning the git repository resulted in the error - Host key verification failed. fatal: The remote end hung up unexpectedly , adding GitHub to the list of known hosts:
You are connecting via the SSH protocol, as indicated by the
The host key forssh://prefix on the clone URL. With SSH, each host has a key. The client remembers the host key associated with a specific address and refuses the connection if the host key changes. This prevents man-in-the-middle attacks.
From here, you can record the updated key yourselfdomain.examplehas been changed. If you feel this is not suspicious , remove the old key domain.example## from your local cache by editing${HOME}/.ssh/known_hostsand removing theline # Or let the SSH utility do it for you
Or, equivalently, havessh
The reason for this prompt is thatdo it for you the next time you connect usinggit fetch,git pullorgit Push(or even a plainssh domain.example), answer "yes"when prompteddomain.example
I strongly recommend that you consider letting users authenticate using keys as well. This wayis no longer in yourknown_hostsafter deletion, and may not be in the system's/etc/ssh/ssh_known_hosts, sosshhas no way of knowing whether the host on the other end of the connection is actuallydomain.example. (If the key in/etcis wrong, someone with administrative rights will have to update the system-wide file.)ssh-agent
can store the key material for convenience (rather than everyone having to enter the password every time they connect to the server), and the password is not transmitted over the network.