远程:用户名或密码无效。致命错误:身份验证失败。

5

我使用Git for Windows。我创建了SSH密钥,并按照这篇文章的说明将其添加到我的GitHub设置中的密钥列表中。现在我尝试使用它,但是我遇到了错误:

$ git push origin master
Username for 'https://github.com': Andrey-Bushman
Password for 'https://Andrey-Bushman@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/Andrey-Bushman/sandbox.git/

我该怎样解决它?

你应该使用用户名 git - Kenney
你能否提供你的 git remote -v 命令的结果? - mim.
1个回答

3

首先,请执行以下命令确保已成功创建了ssh密钥:

$ ssh -T git@github.com

应该会输出以下信息:"Hi Andrey-Bushman! You've successfully authenticated, but GitHub does not provide shell access."

如果没有输出,则请查看SSH Access to Git

完成后,请按照以下步骤进行:

  1. 使用ssh协议克隆存储库,如下所示:

    git@github.com:<github-username>/<repo>.git

    在您的情况下:

    git@github.com:Andrey-Bushman/<repo>.git

  2. 将更改提交到存储库中。

  3. 然后,git push origin <branch-name>

    在您的情况下:

    git push origin master


如果它打印出“Hi Andrey-Bushman!您已成功验证,但GitHub不提供shell访问权限。”是的,它会打印。 - Andrey Bushman
git@github.com:Andrey-Bushman/<repo>.git,我应该在哪里使用它? - Andrey Bushman
2
不,首先你必须使用ssh克隆repo,然后使用origin名称推送它。 - Arpit Aggarwal

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