git clone 别人的github项目会提示Host key verification failed

浏览:59日期:2023-10-31

问题描述

git clone git@github.com:Unknwon/qiniudrive.git 失败!(怎么回事?)

RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx Are you sure you want to continue connecting (yes/no)? Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

clone自己的项目不会出现这样的提示。这是怎么回事?

git clone git://github.com/Unknwon/qiniudrive.git 成功!

为什么git@github.com:Unknwon/qiniudrive.git 失败了???

问题解答

回答1:

git clone git://github.com/Unknwon/qiniudrive.git 这是使用 git 协议。

git@github.com:Unknwon/qiniudrive.git 这是使用 ssh 协议。ssh 会验证对方服务器的 key。它没办法确认服务器出示的 key 是受信的,所以问你这个 key 是不是真的是你要连接的那个服务器的。你没说「yes」所以 ssh 认为你不想继续连接,所以连接失败。

回答2:

实际上这个问题只要 Google 一下就可以解决的。

虽然可以解决,但其实可以了解一下 git 的大致原理。即服务器上一般是有个 git 的用户,而你通过 git 用户去访问项目文件。

那么如何通过 git 登录远程主机获取代码?再去看下 ssh 登录。

而 ssh 的认证有两种方式,一种是输入密码,一种直接 RSA 认证(建议使用 RSA 认证)。在 home 目录下会有个 .ssh 文件夹,用于存放公钥,私钥,known_host,authorized_keys 以及配置文件等。

....此处省略一万字

具体怎么解决你的问题,还是希望你能自行 Google 一下。遇到问题先尝试自己解决,解决不了问 Google ,Google 不到的问题再提会更好。

回答3:

http://itfan.github.io/#show/2013-06-07-use-github-on-windows

相关文章: