在GitHub上使用GitHub桌面版和命令行推送到仓库时,身份验证失败

8
  • 我正在使用Windows 10 64位操作系统上的GitHub Desktop v2.5.7和Git v2.29.1。
  • 我的GitHub账户启用了2FA双重身份验证。
  • 我可以使用GitHub Desktop或命令行克隆从GitHub上的存储库。
  • 我生成了SSL密钥并按照所有说明将其添加到本地和GitHub。
  • 我生成了个人访问令牌,并尝试在命令行中使用此令牌,以及我的密码。

问题:当我尝试将更改推送到存储库时,出现身份验证错误。

GitHub Desktop中的错误:

Screenshot of error - authentication failed. Some common reasons include...

命令行中的错误:

开启SSL验证:

fatal: unable to access 'https://github.com/jacquibo/neo4jDataSets.git/': SSL certificate problem: unable to get local issuer certificate

关闭SSL验证:

info: please complete authentication in your browser...
fatal: incorrect_client_credentials: The client_id and/or client_secret passed are incorrect. [https://docs.github.com/apps/managing-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#incorrect-client-credentials]
Username for 'https://github.com': my@githubemail.co.uk
Password for 'https://my@githubemail.co.uk@github.com':
remote: No anonymous write access.
fatal: Authentication failed for 'https://github.com/myusername/myrepo.git/'

我尝试过:

  • 在GitHub中的错误提示中提供的所有建议。
  • 在本地和GitHub上添加SSH密钥(当我使用ssh -i mycertname -vT git@github.com时,我会收到权限被拒绝的消息,见下文)。
  • 添加个人访问令牌。
  • 检查源是否使用HTTPS。

测试SSL证书时使用命令行出现的错误:

OpenSSH_8.4p1,OpenSSL 1.1.1h 22 Sep 2020
debug1:正在读取配置数据/etc/ssh/ssh_config
debug1:连接到github.com [140.82.121.4]端口22。
debug1:连接地址140.82.121.4端口22:权限被拒绝
ssh:无法连接到主机github.com的端口22:权限被拒绝

如何解决这个问题?

只能编辑实际在GitHub.com上的文件并不是很实际。

2个回答

3
你需要使用SSH访问仓库,而不是HTTPS。
将远程的URL从`https://xxx` 更改为 `git://xxx`。
你可以使用GitHub仓库代码页面右侧的绿色按钮来帮助你获取正确的URL。将链接从: HTTPS URL 修改为: SSH URL 另一件事情是确保你本地安装的Git版本是最新的。如果你安装了旧版本的Git,则可能会遇到错误。

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接