Git错误:“主机密钥验证失败”当连接到远程存储库时 [英] Git error: "Host Key Verification Failed" when connecting to remote repository

查看:2025
本文介绍了Git错误:“主机密钥验证失败”当连接到远程存储库时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接到驻留在我的web服务器上的远程Git存储库,并将其克隆到我的机器。



我对我的命令使用以下格式:

  git克隆ssh://username@domain.com/repository.git 

这对我的大部分团队成员来说都工作得很好。通常在运行此命令后,Git会提示输入用户密码,然后运行克隆。但是,在我的一台机器上运行时,出现以下错误:


主机密钥验证失败。


$ b

致命:无法读取远程
存储库。


我们没有使用SSH密钥连接到这个存储库,所以我不确定Git为什么要在这台特定的机器上检查一个。

您正在通过SSH协议进行连接。使用SSH,每个主机都有一个密钥。客户记住与特定地址关联的主机密钥,并在主机密钥似乎发生更改时拒绝连接。这可以防止中间人攻击。



domain.com的主机密钥已更改。 如果这对您来说看起来不太可笑,您可以使用

  $ ssh-keygen -R domain.com 

我强烈建议您考虑让用户使用密钥进行身份验证以及。这样,为了方便起见, ssh-agent 可以存储密钥材料(而不是每个人都必须输入每次连接到服务器的密码),并且密码不会通过网络。


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://username@domain.com/repository.git

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 repository.

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.

解决方案

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 domain.com has changed. If this does not seem fishy to you, you can remove the old key from your local cache using

$ ssh-keygen -R domain.com

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.

这篇关于Git错误:“主机密钥验证失败”当连接到远程存储库时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆