git TortoiseGit 使用不正确的 SSH 密钥
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5358804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TortoiseGit using incorrect SSH key
提问by Martin
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
目前我对 tortoise git 有一个奇怪的问题,我无法弄清楚。尝试提交到我在 github 上的存储库时出现错误
ERROR: Permission to martindevans/Hermes.git denied to key2
错误:对 martindevans/Hermes.git 的权限被拒绝给 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
Key2 是我用来访问不同 github 存储库的密钥,但是远程 url 未设置为使用 key2,正如您在此处看到的,它设置为使用 private.ppk
Am I doing something obviously wrong, or is tortoise git broken?
我是在做明显错误的事情,还是乌龟 git 坏了?
Nb. In response to the comments. Using normal git results in:
铌。回应评论。使用普通的 git 结果:
C:\Users\Martin\Documents\Visual Studio 2010\Projects\Hermes>git push
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
回答by Doomjunky
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.
有不同的私钥格式。我的密钥对是用 puttygen 生成的,但我的 Tortoise 被配置为使用 ssh.exe(形式 msysgit)作为 ssh-client。所以我将它更改为 plink(来自 Tortoise)并且它起作用了。
- ssh-key.exe => ssh.exe (C:\msysgit\msysgit\bin)
- puttygen.exe => TortoisePlink.exe (C:\Program Files\TortoiseGit\bin)
- 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.
附加说明:使用正确的 URL!Github 为您提供了三个 URL https、git 和 ssh。
Edit:
编辑:
I adapted the settingshere:
我在这里调整了设置:
Settings - TortoiseGit >> Network >> SSH-Client
C:\Program Files\TortoiseGit\bin\TortoisePLink.exe
I have generated the key-pairwith:
我已经生成了密钥对:
C:\Program Files\TortoiseGit\bin\puttygen.exe
回答by scaryman
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.
哈!ProcMon 来救援。这是 tortoisegit / tortoiseplink 中的一个错误。它应该优先考虑通过选美为该远程设置的密钥,但它优先考虑由该特定服务器的腻子存储在注册表中的密钥。两个修复。
2 possible fixes here
这里有 2 个可能的修复
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.
您的tortoiseplink 与putty 集成在一起,它正在读取您保存在与该服务器关联的putty“会话”中的私钥。至少对我来说是这样。我不在 github 上,所以我不知道这个解决方案对每个人的可行性。
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.
我建议在腻子会话配置中手动删除密钥集,并为您的腻子会话使用 pagaent,就像 tortoise git 所做的那样。这也使 tortoisegit 使用遥控器的键集。
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.
You can modify / delete the registry entry yourself. it's
HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\$SERVERNAME$\PublicKeyFile
因此,您可以打开 putty,加载与服务器关联的任何会话,转到 Connection/SSH/Auth 并修改/删除“用于身份验证的私钥文件”值。修改可能会修复此存储库,但如果您对同一服务器使用不同的密钥,则会搞砸另一个存储库。
您可以自行修改/删除注册表项。它是
HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\$SERVERNAME$\PublicKeyFile
回答by we_do_not_exist
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).
我在设置 TortoiseGit 以访问 Bitbucket (Win10) 时遇到了同样的问题。为了解决它,我必须删除注册表中旧的保存的主机键HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys
(不是(默认)键,tho)。
回答by Adam Dymitruk
create the key in git bash:
在 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.
将所有内容留空,不要设置密码。把~/.ssh/id_rsa.pub的内容粘贴到github提供的公钥空间。
Now test this by connecting to github via ssh. If that works, you will be able to use git.
现在通过 ssh 连接到 github 来测试这个。如果可行,您将能够使用 git。
hope this helps.
希望这可以帮助。