我有一个在GitHub上托管的项目.我试图推动我对主人的修改时失败了.我总是收到以下错误消息
Password for 'https://git@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://git@github.com/eurydyce/MDANSE.git/'
Run Code Online (Sandbox Code Playgroud)
但是,将我的ssh密钥设置为github似乎没问题.的确,当我做的时候,ssh -T git@github.com
我得到了
Hi eurydyce! You've successfully authenticated, but GitHub does not provide shell access.
Run Code Online (Sandbox Code Playgroud)
这似乎表明从那一方来说一切正常(eurydyce是我的github用户名).我严格遵循github上给出的指令和许多堆栈讨论的建议,但没办法.你知道我做错了什么吗?
Oli*_*ver 856
实现双因素认证(2FA)后,您可能会看到这样的尝试时使用git clone
,git fetch
,git pull
或git push
:
$ git push origin master
Username for 'https://github.com': your_user_name
Password for 'https://your_user_name@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/your_user_name/repo_name.git/'
Run Code Online (Sandbox Code Playgroud)
启用2FA后,您需要输入个人访问令牌,而不是2FA代码和GitHub密码.
...
例如,当您访问使用类似的命令在命令行中使用Git存储库
git clone
,git fetch
,git pull
或git push
使用HTTPS URL,则必须输入用户名和密码时,提供您GitHub的用户名和您个人的访问令牌.命令行提示符不会指定您在要求输入密码时应输入个人访问令牌.
相关问题:https: //stackoverflow.com/a/21374369/101662
Von*_*onC 217
https://git@github.com/eurydyce/MDANSE.git不是一个ssh url,它是一个https(需要你的GitHub帐户名,而不是' git
').
尝试使用ssh://git@github.com:eurydyce/MDANSE.git
或只是git@github.com:eurydyce/MDANSE.git
git remote set-url origin git@github.com:eurydyce/MDANSE.git
Run Code Online (Sandbox Code Playgroud)
该OP佩莱格里尼埃里克补充说:
这就是我在我的
~/.gitconfig
文件中所做的,目前包含以下条目[remote "origin"] url=git@github.com:eurydyce/MDANSE.git
这不应该在您的全局配置中(在其中~/
).
您可以检查git config -l
您的仓库:该URL应该在本地配置中声明:<yourrepo>/.git/config
.
因此,在执行git remote set-url
命令时请确保您处于repo路径中.
小智 65
解决步骤:
Ahm*_*ais 43
如果像我这样你只是更新了你的密码并跑去
git push
遇到这个问题,那么这是一个非常简单的解决方案.
仅限Mac用户.您需要删除GitHub的OSX Keychain访问条目.您可以通过运行以下命令通过终端执行此操作.
通过命令行,您可以直接使用凭证帮助程序擦除钥匙串条目.
为此,请键入以下命令:
git credential-osxkeychain erase
host=github.com
protocol=https
# [Now Press Return]
Run Code Online (Sandbox Code Playgroud)
如果成功,则不会打印出任何内容.要测试它是否有效,请尝试从GitHub克隆存储库,或者像我的情况一样再次运行您之前的操作git push
.如果系统提示您输入密码,则会删除钥匙串条目.
pok*_*oke 24
使用https://
URL连接到远程存储库时,Git不会使用SSH作为身份验证,而是尝试通过HTTPS进行基本身份验证.通常,您只需使用没有用户名的URL,例如https://github.com/username/repository.git
,然后Git会提示您输入用户名(您的GitHub用户名)和密码.
如果你使用https://something@github.com/username/repository.git
,那么你已经预设了Git将用于身份验证的用户名:something
.自从您使用以来https://git@github.com
,Git将尝试使用git
您的密码当然不起作用的用户名登录.因此,您必须使用您的用户名.
替代方案实际上是使用SSH进行身份验证.这样你就不必一直输入你的密码; 并且因为它似乎已经起作用,所以你应该使用它.
为此,您需要更改远程URL,因此Git知道它需要通过SSH连接.格式是这样的:git@github.com:username/repository
.要更新您的URL,请使用以下命令:
git remote set-url origin git@github.com:username/repository
Run Code Online (Sandbox Code Playgroud)
sag*_*thi 23
2FA 已启用并收到远程错误:用户名或密码无效。致命:身份验证失败
如果您在 GitHub 中设置 2FA 已启用,您将需要输入个人访问令牌而不是 2FA 代码和您的 GitHub 密码。
如何修复
Jul*_*edo 21
这就是答案。
设置 github 令牌:
https://github.com/settings/tokens
进而:
git remote set-url origin https://[token]@github.com/your_repository
Run Code Online (Sandbox Code Playgroud)
小智 15
只是尝试再次将其推送到您的分支机构.这将再次询问您的用户名和密码,因此您可以输入更改的密码.这样您的新密码将再次存储在缓存中.
Saz*_*han 11
由于密码错误,有时会发生该问题。请检查您是否使用 AD 密码(Active Directory 密码)链接,并且您最近更改了 AD 密码但仍在尝试使用旧密码执行 git 命令。
更新旧的 AD 密码
Control Panel > Credential Manager > Windows Credential > change github password with my new AD password
Run Code Online (Sandbox Code Playgroud)
Arp*_*ini 11
运行下面的命令,然后在每次推送和拉取之后,它都会要求您输入用户名和密码。
git config credential.helper ""
Run Code Online (Sandbox Code Playgroud)
现在,当您拉/推时,系统会要求您提供 git 凭据。无论您是通过命令提示符还是 Intellij Git 运行。
小智 9
我做了:
$git pull origin master
Run Code Online (Sandbox Code Playgroud)
然后它要求输入 [用户名] 和 [密码],现在似乎工作正常。
小智 9
如果您刚刚启用 2FA :
修改隐藏文件夹config
中的隐藏文件./git
如下:
[remote "origin"]
url = https://username:PUT_YOUR_2FA_TOKEN_HERE@github.com/project/project.git
Run Code Online (Sandbox Code Playgroud)
无需依赖生成个人访问令牌,然后尝试使用个人访问令牌代替您的密码。
快速修复是将您的远程 URL 设置为指向ssh
not https
。
做这个 git remote set-url origin git@github.com:username/repository
而不是git pull
也尝试git pull origin master
我更改了密码,第一个命令给出了错误:
$ git pull
remote: Invalid username or password.
fatal: Authentication failed for ...
Run Code Online (Sandbox Code Playgroud)
之后git pull origin master
,它要求输入密码,并且似乎会自动更新
小智 7
我在从 bitbucket 克隆应用程序时得到这个:
Cloning into 'YourAppName'...
Password for 'https://youruser id':
remote: Invalid username or password
Run Code Online (Sandbox Code Playgroud)
我解决了。在这里您需要为您的用户 ID 创建密码
小智 7
尝试这个:
# git remote set-url origin git@github.com:username/repository
Run Code Online (Sandbox Code Playgroud)
小智 6
我使用以下命令取得了成功。
git config --unset-all credential.helper
git config --global --unset-all credential.helper
git config --system --unset-all credential.helper
Run Code Online (Sandbox Code Playgroud)
尝试让我知道这些是否适合您。
归档时间: |
|
查看次数: |
305845 次 |
最近记录: |