【问题标题】:git - Server host key not cached - Windows twistgit - 未缓存服务器主机密钥 - Windows 扭曲
【发布时间】:2014-12-27 00:30:05
【问题描述】:

我遇到了与 git - Server host key not cached 中的问题类似的问题,但有一个转折点导致那里的最佳解决方案不起作用。

我正在尝试从 Stash 克隆一个存储库,这是一个来自 Atlassian 的应用程序,例如我们公司用于存储其 git 存储库的 git-hub。在我将公钥输入 Stash 后,我使用 Git Bash 尝试使用系统提供的 ssh 地址从那里克隆存储库。结果如下:

$ git clone ssh://git@stash.mycompany.com:7999/teamproject/gitrepo.git
Cloning into 'gitrepo'...
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:12
Connection abandoned.
fatal: Could not read from remote repository.

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

由于我没有使用putty尝试连接,所以尝试了用ssh连接服务器的方案:

$ ssh ssh://git@stash.mycompany.com:7999/teamproject/gitrepo.git
ssh: stash.mycompany.com:7999/teamproject/gitrepo.git: no address associated with name

如果我尝试缩短 ssh 可以识别的地址,我得到的指纹与 git 拒绝的指纹不同:

$ ssh ssh://git@stash.mycompany.com
The authenticity of host 'stash.mycompany.com (10.XX.XXX.XX)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:34.
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.

我选择不继续连接,因为如果我确实连接了,它只是将一个不能帮助 git 完成其工作的条目放入我的 known_hosts 文件中。

有人知道如何解决这个问题吗?

【问题讨论】:

  • 所以从长远来看,没有“让最好的解决方案不起作用的扭曲”,它只是奏效了。

标签: git ssh git-bash bitbucket-server


【解决方案1】:

我有一位同事给了我一个提示,最终让我解决了我的问题。我在上面发布的直接问题的答案是我没有以预期的格式向 ssh 提供端口号。你不用这样指定端口号...

ssh stash.mycompany.com:7999

...而是像这样:

ssh -p 7999 stash.mycompany.com

这种语法导致 ssh 询问我是否要将主机存储在已知主机列表中,它给了我 Stash 告诉我它应该使用的指纹。 (在我说是之后,ssh 挂断了我的 Git Bash 提示,我不得不终止整个 Git Bash 会话并开始一个新会话。但至少主机已经存储在 known_hosts 文件中。:)

一旦我解决了这个问题,我唯一要做的就是在这个线程 github: No supported authentication methods available 中应用一个解决方案,即在我的 .bash_profile 中为 Git Bash 设置 GIT_SSH 变量

export GIT_SSH=/bin/ssh.exe

完成此操作并重新启动 Git Bash 后,git 开始使用我的 ssh 密钥工作。

【讨论】:

  • 一定要接受答案——即使它是你自己的!这非常有帮助 - 谢谢!
猜你喜欢
  • 2011-06-23
  • 2012-04-27
  • 2012-09-11
  • 1970-01-01
  • 1970-01-01
  • 2015-06-13
  • 1970-01-01
  • 2017-08-08
  • 2018-05-22
相关资源
最近更新 更多