我是 Git 和 GitHub/GitLab 的新手。我尝试将我的项目共享到 GitHub,但它抛出此异常:
Can't finish GitHub sharing process
Successfully created project 'LiveGame1' on GitHub, but initial push failed:
git@github.com: Permission denied (publickey).
Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我还可以通过互联网链接克隆存储库,但不能通过“git@github.com:/username/repository_name”。
如何修复此错误以及我是否可以将我的项目直接共享到 GitLab?
最佳答案
这篇文章帮助我解决了 Windows 10 机器上的问题:
https://richardballard.co.uk/ssh-keys-on-windows-10/
注意:文章第一部分的标题应为“在 Windows 中启用 SSH 客户端”,并应提及获取 SSH 客户端> 启用,而不是服务器。
如果您可以让 ssh -T git@github.com
正常工作而不提示您输入密码(如上面的文章所述),那么您就可以从 IntelliJ 进行推送了。
关键是:
- 获取在 Windows 中运行的 OpenSSH 身份验证代理服务
- 确保调用的
ssh-add
是C:\Windows\System32\OpenSSH
中提供的 - 确保 git 也配置为使用 Windows 提供的 ssh:
git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"
使用ssh-keygen
生成 key 时,请考虑使用ecdsa算法,如下所述:https://www.ssh.com/ssh/keygen/
同样重要的是清理任何其他试图在 Windows 之外执行 ssh 的内容(例如 Putty)。在尝试运行 ssh-add 时,我一直面临“无效格式”的一个问题,我相信这是由我的路径上正在使用的不同的 ssh-add 程序引起的与 Windows 附带的 OpenSSH 相比。
关于github - IntelliJ,无法在 GitHub 上共享项目(权限被拒绝),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54038611/