Sourcetree git 出现 The server‘s host key is not cached in the registry问题的解决办法

省流:

参考博文:https://blog.csdn.net/sryan/article/details/50717528
Sourcetree会自带plink,用命令行切换到plink.exe所在路径,并执行plink [email protected] 命令,根据提示输入y 回车,问题就解决了。本质上是plink问玩家要y还是n,但是在Sourcetree的错误提示那里不能输入。

问题描述:

这几天用Sourcetree Clone自己的项目时遇到如下报错提示:

命令: git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks ls-remote [email protected]:我的用户名/项目名.git
输出:
错误: The host key is not cached for this server:
github.com (port 22)
You have no guarantee that the server is the computer
you think it is.
The server’s ssh-ed25519 key fingerprint is:
ssh-ed25519 255 SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
If you trust this host, enter “y” to add the key to
PuTTY’s cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter “n”.
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n, Return cancels connection, i for more info) fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

错误信息主要有两句:The host key is not cached for this server:
github.com (port 22)
You have no guarantee that the server is the computer
you think it is.
其他都是建议的处理方式。

看起来提示内容是命令行常用的操作方式,但SourceTree的错误提示是不能输入(y/n)的,所以就卡住了。

解决思路:

搜上文的错误提示相关的文章很少,只有文章开头的那个和我的情况最相近(但该文只有两行)。
但根据该文推测,这个错误提示是Sourcetree使用的一个工具plink报出来的,而且可能不是Sourcetree常见问题所以没有直接解决的选项。

随Sourcetree安装的plink工具在安装路径 SourceTree\app-3.4.11\tools\putty 路径下。没有可视化界面所以双击打不开,需要用命令行打开直接操作。

之前的报错信息大意是“没有缓存此服务器的主机密钥:github.com (port 22) 如果信任就缓存,或者允许一次,也可以取消。”所以我们直接使用plink链接github,尝试复现这个提示。

切换路径到SourceTree\app-3.4.11\tools\putty后,直接输入 plink [email protected],这里的地址是错误提示中出现过的。回车后果然出现了一样的错误提示,输入y缓存github密钥。问题解决。

(ps.这里可能还会出现一个错误提示,因为我们输入的plink命令参数只有主机地址没有用户名,但只要它缓存了主机密钥,我们的问题就解决了。)

扫描二维码关注公众号,回复: 15262771 查看本文章

我不了解plink,还需要进一步查找资料。欢迎各位大佬讨论指正。

猜你喜欢

转载自blog.csdn.net/Player1MacHN/article/details/129137060