TortoiseGit 使用不正确的 SSH 密钥

发布于 2024-10-23 22:03:20 字数 533 浏览 2 评论 0原文

我现在有一个关于乌龟git的奇怪问题,我无法弄清楚。当尝试提交到 github 上的存储库时,出现错误

错误:对 key2 的 martindevans/Hermes.git 权限被拒绝

Key2 是我用来访问不同 github 存储库的密钥,但是远程 url 未设置为使用 key2,正如您在此处看到的,它设置为使用 private.ppk

在此处输入图像描述

我是否在做一些明显错误的事情,或者是乌龟 git 损坏了?

铌。回应评论。使用普通 git 会导致:

C:\Users\Martin\Documents\Visual Studio 2010\Projects\Hermes>git push
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

I have a strange problem with tortoise git at the moment, which I can't figure out. When trying to commit to my repository on github I get the error

ERROR: Permission to martindevans/Hermes.git denied to key2

Key2 is a key I use to access a different github repository, however the remote url is not set to use key2, as you can see here it's set to use private.ppk

enter image description here

Am I doing something obviously wrong, or is tortoise git broken?

Nb. In response to the comments. Using normal git results in:

C:\Users\Martin\Documents\Visual Studio 2010\Projects\Hermes>git push
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

千秋岁 2024-10-30 22:03:20

有不同的私钥格式。我的密钥对是用 puttygen 生成的,但我的 Tortoise 配置为使用 ssh.exe(来自 msysgit)作为 ssh 客户端。所以我把它改为 plink (来自 Tortoise)并且它起作用了。

  • ssh-key.exe =>; ssh.exe (C:\msysgit\msysgit\bin)
  • puttygen.exe => TortoisePlink.exe (C:\Program Files\TortoiseGit\bin)

附加说明:使用正确的 URL! Github 为您提供了三个 URL https、git 和 ssh。


编辑:

我在这里调整了设置

Settings - TortoiseGit >> Network >> SSH-Client
C:\Program Files\TortoiseGit\bin\TortoisePLink.exe

我使用以下命令生成了密钥对

 C:\Program Files\TortoiseGit\bin\puttygen.exe

There are different private key formats. My keypair was generated with puttygen, but my Tortoise was configured to use ssh.exe (form msysgit) as ssh-client. So i changed it to plink (from Tortoise) and it worked.

  • ssh-key.exe => ssh.exe (C:\msysgit\msysgit\bin)
  • puttygen.exe => TortoisePlink.exe (C:\Program Files\TortoiseGit\bin)

Additional note: Use the correct URL! Github offers you three URL https, git and ssh.


Edit:

I adapted the settings here:

Settings - TortoiseGit >> Network >> SSH-Client
C:\Program Files\TortoiseGit\bin\TortoisePLink.exe

I have generated the key-pair with:

 C:\Program Files\TortoiseGit\bin\puttygen.exe
泛泛之交 2024-10-30 22:03:20

哈! ProcMon 来救援。这是 tortoisegit / tortoiseplink 中的一个错误。它应该优先考虑通过选美为该远程设置的密钥,但它优先考虑由 putty 为该特定服务器存储在注册表中的密钥。两个修复。

这里有 2 个可能的修复方法

您的 tortoiseplink 与 putty 集成,并且它正在读取您保存在与该服务器关联的 putty“会话”中的私钥。至少对我来说就是这样。不过我不在 github 上,所以我不知道这个解决方案对每个人来说是否可行。

我建议在 putty 会话配置中手动删除密钥集,并在 putty 会话中使用 pagaent,因为这就是 tortoise git 所做的。这也使得 tortoisegit 使用遥控器的按键集。

  1. 因此,您可以打开 putty,加载与服务器关联的任何会话,转到“连接/SSH/身份验证”并修改/删除“用于身份验证的私钥文件”值。修改可能会修复此存储库,但如果您对同一服务器使用不同的密钥,则会搞砸另一个存储库。

  2. 您可以自行修改/删除注册表项。
    它是 HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\$SERVERNAME$\PublicKeyFile

Hah! ProcMon to the rescue. This is a bug in tortoisegit / tortoiseplink. It should give preference to the key set for that remote via pageant, but instead it gives preference to the key stored in the registry by putty for that specific server. Two fixes.

2 possible fixes here

Your tortoiseplink is integrated with putty, and it's reading the private key you have saved in the putty "Session" associated with that server. At least that's what it was for me. I'm not on github though, so I don't know the viability of this solution for everybody.

I'd recommend deleting the key set manually in the putty session configuration and using pagaent for your putty sessions, as that's what tortoise git does. This also makes tortoisegit use the key set for the remote.

  1. So, you can open up putty, load whatever session you have associated with the server, go to the Connection/SSH/Auth and modify / remove the "Private key file for authentication" value. MOdification may fix this repo but then screw up another repo if you are using different keys for the same server.

  2. You can modify / delete the registry entry yourself.
    it's HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\$SERVERNAME$\PublicKeyFile

风和你 2024-10-30 22:03:20

我在设置 TortoiseGit 访问 Bitbucket (Win10) 时遇到了同样的问题。要解决此问题,我必须删除注册表中 HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys 中旧保存的主机密钥(不是(默认)密钥)。

I had the same problem setting up my TortoiseGit to access Bitbucket (Win10). To resolve it I had to delete the old saved host keys in the registry at HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys (not the (Default) key, tho).

泛滥成性 2024-10-30 22:03:20

在 git bash 中创建密钥:

ssh-keygen -t rsa

将所有内容留空并且不设置密码。将 ~/.ssh/id_rsa.pub 的内容粘贴到 github 提供的公钥空间中。

现在通过 ssh 连接到 github 来测试这一点。如果可行,您将能够使用 git。

希望这有帮助。

create the key in git bash:

ssh-keygen -t rsa

Leave everything blank and don't set a password. Take the contents of the ~/.ssh/id_rsa.pub and paste it into the public key space provided by github.

Now test this by connecting to github via ssh. If that works, you will be able to use git.

hope this helps.

不…忘初心 2024-10-30 22:03:20

我在推送到 GitHub 时遇到了随机出现的这个错误。我尝试了此处列出的所有内容,但均无济于事。我的密钥仍然没问题 - 我仍然可以通过 ssh -vT [email protected] 进行连接] 并且可以通过 Git Bash 推送/拉取。

我什至重现了 TortoiseGit 使用新密钥工作,然后切换回旧密钥并失败,然后切换回新密钥并失败。因此,这似乎是 TortoiseGit 与 PuTTY 集成中的一个错误,尽管不是上面 @scaryman 评论中列出的错误。

最后,以下工作成功了:

  1. 升级到最新的 PuTTY 和 TortoiseGit
  2. 使用 Puttygen 创建一个新的 PPK 并将公钥添加到 GitHub
  3. 使用新的 PPK Open Pageant 从 TortoiseGit 进行拉取
  4. 并删除旧的 SSH 密钥,因此新密钥是唯一列出的一个。
  5. 删除旧的 PPK 并从 Github 中删除其公钥。这将强制所有使用旧 PPK 的存储库在您第一次连接到 GitHub 时出错,然后它们会自动切换到您的新 PPK。

I had this exact error that randomly appeared when doing a push to GitHub. I tried everything listed here to no avail. My key was still fine - I could still connect via ssh -vT [email protected] and could push/pull via Git Bash.

I even reproduced TortoiseGit working with a new key, then switching back to the old key and failing, then switching back to the new key and failing. So this seems to be a bug in TortoiseGit's integration with PuTTY, although not the one listed in @scaryman's comment above.

In the end the following worked:

  1. Upgrade to the latest PuTTY and TortoiseGit
  2. Create a new PPK using Puttygen and add the public key to GitHub
  3. Do a pull from TortoiseGit using the new PPK
  4. Open Pageant and remove the old SSH key, so the new key is the only one listed.
  5. Delete the old PPK and remove its public key from Github. This will force all repos using the old PPK to error the first time you connect to GitHub, then they automatically switch to your new PPK.
和影子一齐双人舞 2024-10-30 22:03:20

就我而言,TortoiseGit 使用的密钥是

HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings\PublicKeyFile

删除该值后,我能够使用正确的密钥提取存储库。

In my case the TortoiseGit used the key that was in

HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings\PublicKeyFile

After removeing the value, I was able to pull a repo with the correct key.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文