无法使用 Windows 使用 ssh 密钥访问 gitlab 存储库

问题描述:

我已按照这些说明使用 ssh-keygen 生成密钥对.我实际上同时生成了 ed25519 和一个 rsa 密钥,因为我试图找出问题所在.

I have followed these instructions for generating keypairs using ssh-keygen. I actually generated both the ed25519 and an rsa key as I attempted to figure out what was wrong.

我根据他们的说明在 gitlab 中复制并粘贴了这两个密钥的公钥对.

I copied and pasted the public key pair for both of these keys in gitlab according to their instructions.

当我输入:ssh -T git@gitlab.com 它说:

client_global_hostkeys_private_confirm:服务器为 RSA 密钥 0 提供了错误的签名

但它也说Welcome to gitlab, @my_username!

当我尝试推送到我的存储库时,我收到一个弹出窗口,询问我输入的 gitlab 用户名和密码,但失败了.

when I try to push to my repo, I get a popup asking for my gitlab username and password which I enter and which fails.

考虑到我已尝试建立 SSH 密钥对进行身份验证,我不明白为什么它会提示我输入用户名和密码.

I don't understand why it is prompting me for a username and password considering that I have attempted to establish SSH keypairs for authentication.

感谢任何建议

我收到一个弹出窗口,询问我输入的 gitlab 用户名和密码,但失败了.

I get a popup asking for my gitlab username and password which I enter and which fails.

检查,如评论:

  • git remote -v
  • git config credential.helper

如果第一个以 https:// 开头,并且第二个不为空,则您看到的是一个 Git 凭据帮助程序,它试图缓存您的 HTTPS 凭据.
这意味着您的 SSH 密钥无论如何都会被忽略.

If the first starts with https://, and the second is not empty, what you see is a Git credential helper trying to cache your HTTPS credentials.
That means your SSH key would be ignored anyway.

关于错误消息,请查看此线程,以及测试它:

Regarding the error message, check out this thread, and test it with:

ssh -o UpdateHostKeys=no -Tv git@gitlab.com

为了使其持久化,在~/.ssh/config中:

To make it persistent, in ~/.ssh/config:

Host gitlab.com
  UpdateHostKeys no