git GitHub 身份验证通过 https 失败,返回错误的电子邮件地址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20913962/
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
GitHub authentication failing over https, returning wrong email address
提问by ele
Initiating a push or any other action with GitHub from the command line (over https, not ssh) that calls for the username and password not only fails but, when it does, it returns
从命令行(通过 https,而不是 ssh)使用 GitHub 启动推送或任何其他操作,调用用户名和密码不仅会失败,而且会返回
Username for 'https://github.com': username
Password for 'https://[email protected]':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/username/repository.git/'
I do not have an @github.com
address. The password and username are correct.
我没有@github.com
地址。密码和用户名是正确的。
I know I could switch to SSH and use keys but that doesn't answer why the authentication is failing over https.
我知道我可以切换到 SSH 并使用密钥,但这并不能解释为什么身份验证通过 https 失败。
回答by ele
GitHub's support determined the root of the issue right away: Two-factor authorization.
GitHub 的支持立即确定了问题的根源:双因素授权。
To use GitHub over the shell with https, create an OAuth token. As the page notes, I did have to remove my username and password credentials from Keychain but with osx-keychain
in place, the token is stored as the password and things work exactly as they would over https without two-factor authorization in place.
要在带有 https 的 shell 上使用 GitHub,请创建一个 OAuth 令牌。正如页面所指出的,我确实必须从 Keychain 中删除我的用户名和密码凭据,但osx-keychain
在适当的位置,令牌存储为密码,并且在没有两因素授权的情况下,事情的工作方式与通过 https 完全一样。
回答by VonC
I do not have an
@github.com
address
我没有
@github.com
地址
You don't have to: the @
is the separator between the username:password and the domain.
It is not an email address.
您不必:@
是用户名:密码和域之间的分隔符。
它不是电子邮件地址。
A full GitHub https url would be:
一个完整的 GitHub https 网址是:
https://username:[email protected]/username/reponame.git
Without the password (which would then be asked on the command line), that would gave:
如果没有密码(然后会在命令行上询问),则会给出:
https://[email protected]/username/reponame.git
But again, [email protected]
isn't an email address, just the first part of the credentials.
但同样,[email protected]
不是电子邮件地址,只是凭据的第一部分。
Make sure the case of your username
and reponame
is correct: it is case sensitive.
确保您的username
和的大小写reponame
正确:区分大小写。
Note that you can store and encrypt your credentials in a .netrc.gpg
(or _netrc.gpg
on Windows) if you don't want to put said credentials in clear in the url.
See "Is there a way to skip password typing when using https://github
".
请注意,如果您不想在 url 中清楚地放置所述凭据,则可以在.netrc.gpg
(或_netrc.gpg
在 Windows 上)存储和加密您的凭据。
请参阅“是否有办法在使用时跳过密码输入https://github
”。
回答by Oyebisi Jemil
- Go to Credential Manager => Windows Manager
- Delete everything related to tfs
Now click on Add a generic credentialand provide the following values
(1) Internet or network adress: git:https://tfs.donamainname (2) username: your username (3) password: your password
this should fix it
- 转到凭据管理器 => Windows 管理器
- 删除与 tfs 相关的所有内容
现在单击添加通用凭据并提供以下值
(1) Internet 或网络地址:git: https://tfs.donamainname (2) username:您的用户名 (3) password:您的密码
这应该解决它
回答by Random
It may happen in Windows if you stored a different credentials before. Go to Credential Manager and delete stored github credentials
如果您之前存储了不同的凭据,则在 Windows 中可能会发生这种情况。转到凭据管理器并删除存储的 github 凭据
回答by Dan Rosenstark
[Mac only]
[仅限 Mac]
If you need to delete your authentication, use
如果您需要删除您的身份验证,请使用
git credential-osxkeychain erase
host=github.com
protocol=https
on Mac.
在 Mac 上。
See https://help.github.com/articles/updating-credentials-from-the-osx-keychain/
请参阅https://help.github.com/articles/updating-credentials-from-the-osx-keychain/
回答by palak
Same thing happened with me, when i have enabled 2-way authentication for github. Things i did to resolve:
当我为 github 启用 2 向身份验证时,我也发生了同样的事情。我做的事情来解决:
- Get you personal access token. This you have to check and generate if not available already. Link for this: https://github.com/settings/tokens
- Go to your local and delete folder and re-clone branch from github.
- Now try the command you were trying earlier i.e: git pull origin master
- Enter username and In password paste the tokengenerated and also don't forget to save that token somewhere, so you can re-use if required.
- 获取您的个人访问令牌。如果不可用,您必须检查并生成。链接:https: //github.com/settings/tokens
- 转到您的本地并删除文件夹并从 github 重新克隆分支。
- 现在尝试您之前尝试的命令,即: git pull origin master
- 输入用户名和密码粘贴生成的令牌,也不要忘记将该令牌保存在某处,以便您可以在需要时重新使用。
Doing this will solve your issue.
这样做将解决您的问题。
回答by Joel Balmer
Just incase this helps anyone else also, I was signed into the mac app, command line working fine, but because I then turned on 2FA, my commands were returning the error. I had to sign out of the app, then I could use my Personal access token in my commands as per ele's answer here.
以防万一这对其他人也有帮助,我登录了 mac 应用程序,命令行工作正常,但是因为我打开了 2FA,我的命令返回了错误。我不得不签署应用出来,那么我可以用我的个人访问令牌在我的命令,每ELE的答案在这里。
Hopefully that helps someone!
希望这可以帮助某人!
回答by Vortex
On Windows, you may be silently blocked by your Antivirus or Windows firewall. Temporarily turn off those services and push/pull from remote origin.
在 Windows 上,您可能会被防病毒软件或 Windows 防火墙静默阻止。暂时关闭这些服务并从远程源推/拉。