【发布时间】:2014-10-22 09:57:41
【问题描述】:
我刚刚启用了 2FA(我想不出我所做的任何其他更改)并且 git 询问了我的用户名和密码。我提供了两者,但它们是“错误的”。我在这里尝试了许多解决方案:Git push requires username and password 但这不起作用。特别是从 https 切换到 ssh 时,ssh 键给出
权限被拒绝(公钥)。 致命:无法从远程存储库读取。
$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Username for 'https://github.com': **********
Password for 'https://mlbileschi@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/mlbileschi/scala.git/'
有什么建议吗?
【问题讨论】:
-
“权限被拒绝(公钥)。致命:无法从远程存储库读取。”是一个单独的问题,可以通过为您的帐户设置 SSH 密钥来解决:help.github.com/articles/…
-
通常这不是 2FA 问题,而是通过从 https 更改为 git 解决
-
如果您只是设置了 GitHub CLI,这个问题就会消失,并且不再要求您进行身份验证。安装并验证 GitHub CLI (
gh),问题就消失了。首先,使用the project README 的说明下载GH CLI,然后按照manual 进行身份验证。按照终端中的说明进行操作,当 GH CLI 完成身份验证后,git push不再需要密码。
标签: git github two-factor-authentication