因此,我在使用 git 和 Github 时遇到了这个问题,当我使用终端时,事情按预期工作,但是从 Git GUI 客户端(如 GitHub 桌面应用程序、SourceTree、Fork 等)中执行任何操作都会给我权限被拒绝(公钥)问题。
甚至尝试像 ssh -T git@github.com
这样的命令在终端中,按预期工作。这是 Fork 中我的 Github 帐户设置的屏幕截图:如您所见,看起来甚至我的 SSH key 都已正确配置并且似乎已被识别。我想避免生成新的 SSH key 并在 GitHub 中设置它的过程,除非实际上没有其他选择。
最佳答案
Even trying out commands like ssh -T git@github.com in the terminal, works as expected.
在这些 GUI 客户端中仔细检查用于远程存储库的 SSH URL。
应该是
git@github.com:<me>/<myrepo>
.如,如我 mentioned here ,在启动 GitHub Desktop 之前先尝试:
git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"
(假设这里是 Windows 10)
对于 Mac,请遵循“How to Manage Multiple SSH Keys”并确保您的 key 已添加到 ssh-agent:
ssh-add -K ~/.ssh/_id_rsa
与
~/.ssh/config
Host *
AddKeysToAgent yes
UseKeychain yes
SSH will look for key in keychain and if it finds it you will not be prompted for password.
Key will also be added to ssh-agent. On MacOS this will work on MacOS Sierra 10.12.2 or later.
关于Git SSH 问题 : Terminal works fine, 但所有 GUI 客户端都失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62090300/