GitHub:用户名或密码无效_password cannot include your login-程序员宅基地

技术标签: github  git  

本文翻译自:GitHub: invalid username or password

I have a project hosted on GitHub. 我有一个在GitHub上托管的项目。 I fail when trying to push my modifications on the master. 我试图推动我对主人的修改时失败了。 I always get the following error message 我总是收到以下错误消息

Password for 'https://[email protected]': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://[email protected]/eurydyce/MDANSE.git/'

However, setting my ssh key to github seems ok. 但是,将我的ssh密钥设置为github似乎没问题。 Indeed, when I do a ssh -T [email protected] I get 的确,当我做一个ssh -T [email protected]我明白了

Hi eurydyce! You've successfully authenticated, but GitHub does not provide shell access.

Which seems to indicate that everything is OK from that side (eurydyce being my github username). 这似乎表明从那一方来说一切正常(eurydyce是我的github用户名)。 I strictly followed the instructions given on github and the recommendations of many stack discussion but no way. 我严格遵循github上给出的指令和许多堆栈讨论的建议,但没办法。 Would you have any idea of what I may have done wrong? 你知道我做错了什么吗?


#1楼

参考:https://stackoom.com/question/1yvWk/GitHub-用户名或密码无效


#2楼

https://[email protected]/eurydyce/MDANSE.git is not an ssh url, it is an https one (which would require your GitHub account name, instead of ' git '). https://[email protected]/eurydyce/MDANSE.git不是一个ssh url,它是一个https(需要你的GitHub帐户名,而不是' git ')。

Try to use ssh://[email protected]:eurydyce/MDANSE.git or just [email protected]:eurydyce/MDANSE.git 尝试使用ssh://[email protected]:eurydyce/MDANSE.git或者只是[email protected]:eurydyce/MDANSE.git

git remote set-url origin [email protected]:eurydyce/MDANSE.git

The OP Pellegrini Eric adds: OP Pellegrini Eric补充道:

That's what I did in my ~/.gitconfig file that contains currently the following entries [remote "origin"] [email protected]:eurydyce/MDANSE.git 这就是我在~/.gitconfig文件中所做的,其中包含当前以下条目[remote "origin"] [email protected]:eurydyce/MDANSE.git

This should not be in your global config (the one in ~/ ). 这不应该在你的全局配置中( ~/ )。
You could check git config -l in your repo: that url should be declared in the local config: <yourrepo>/.git/config . 您可以在您的仓库中检查git config -l :该url应该在本地配置中声明: <yourrepo>/.git/config

So make sure you are in the repo path when doing the git remote set-url command. 因此,在执行git remote set-url命令时,请确保您处于repo路径中。


#3楼

When using the https:// URL to connect to your remote repository, then Git will not use SSH as authentication but will instead try a basic authentication over HTTPS. 使用https:// URL连接到远程存储库时,Git不会使用SSH作为身份验证,而是尝试通过HTTPS进行基本身份验证。 Usually, you would just use the URL without a username, eg https://github.com/username/repository.git , and Git would then prompt you to enter both a username (your GitHub username) and your password. 通常,您只需使用不带用户名的URL,例如https://github.com/username/repository.git ,然后Git会提示您输入用户名(您的GitHub用户名)和密码。

If you use https://[email protected]/username/repository.git , then you have preset the username Git will use for authentication: something . 如果您使用https://[email protected]/username/repository.git ,那么您已预设Git将用于身份验证的用户名: something Since you used https://[email protected] , Git will try to log in using the git username for which your password of course doesn't work. 由于您使用了https://[email protected]将尝试使用您的密码当然不起作用的git用户名登录。 So you will have to use your username instead. 因此,您必须使用您的用户名。

The alternative is actually to use SSH for authentication. 替代方案实际上是使用SSH进行身份验证。 That way you will avoid having to type your password all the time; 这样你就不必一直输入你的密码; and since it already seems to work, that's what you should be using. 并且因为它似乎已经起作用,所以你应该使用它。

To do that, you need to change your remote URL though, so Git knows that it needs to connect via SSH. 为此,您需要更改远程URL,因此Git知道它需要通过SSH连接。 The format is then this: [email protected]:username/repository . 格式如下: [email protected]:username/repository To update your URL use this command: 要更新您的URL,请使用以下命令:

git remote set-url origin [email protected]:username/repository

#4楼

After enabling Two Factor Authentication (2FA), you may see something like this when attempting to use git clone , git fetch , git pull or git push : 启用双因素身份验证(2FA)后,您可能会在尝试使用git clonegit fetchgit pullgit push时看到类似的内容:

$ git push origin master
Username for 'https://github.com': your_user_name
Password for 'https://[email protected]': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/your_user_name/repo_name.git/'

Why this is happening 为什么会这样

From the GitHub Help documentation : GitHub帮助文档

After 2FA is enabled you will need to enter a personal access token instead of a 2FA code and your GitHub password. 启用2FA后,您需要输入个人访问令牌,而不是2FA代码和GitHub密码。

... ...

For example, when you access a repository using Git on the command line using commands like git clone , git fetch , git pull or git push with HTTPS URLs, you must provide your GitHub username and your personal access token when prompted for a username and password. 例如,当您使用Git git clonegit fetchgit pull或带有HTTPS URL的git push等命令在命令行上使用Git访问存储库时,在提示输入用户名和密码时,必须提供GitHub用户名和个人访问令牌。 。 The command line prompt won't specify that you should enter your personal access token when it asks for your password. 命令行提示符不会指定您在要求输入密码时应输入个人访问令牌。

How to fix it 如何解决它

  1. Generate a Personal Access Token . 生成个人访问令牌 (Detailed guide on Creating a personal access token for the command line .) (有关为命令行创建个人访问令牌的详细指南。)
  2. Copy the Personal Access Token. 复制个人访问令牌。
  3. Re-attempt the command you were trying and use Personal Access Token in the place of your password. 重新尝试您尝试的命令,并使用个人访问令牌代替您的密码。

Related question: https://stackoverflow.com/a/21374369/101662 相关问题: https//stackoverflow.com/a/21374369/101662


#5楼

just try to push it to your branch again. 只是尝试再次将其推送到您的分支机构。 This will ask your username and password again, so you can feed in the changed password. 这将再次询问您的用户名和密码,因此您可以输入更改的密码。 So that your new password will be stored again in the cache. 这样您的新密码将再次存储在缓存中。


#6楼

If like me you just updated your password and ran git push to run into this issue, then there's a super easy fix. 如果像我一样你刚刚更新了你的密码并运行git push来解决这个问题,那么就有一个非常简单的解决方法。

For Mac users only. 仅限Mac用户。 You need to delete your OSX Keychain access entries for GitHub. 您需要删除GitHub的OSX Keychain访问条目。 You can do it via terminal by running the following commands. 您可以通过运行以下命令通过终端执行此操作。

Deleting your credentials via the command line 通过命令行删除凭据

Through the command line, you can use the credential helper directly to erase the keychain entry. 通过命令行,您可以直接使用凭证帮助程序擦除钥匙串条目。

To do this, type the following command: 为此,请键入以下命令:

git credential-osxkeychain erase
host=github.com
protocol=https

# [Now Press Return]

If it's successful, nothing will print out. 如果成功,则不会打印出任何内容。 To test that it works, try and clone a repository from GitHub or run your previous action again like in my case git push . 要测试它是否有效,请尝试从GitHub克隆存储库,或者像我的git push一样再次运行您之前的操作。 If you are prompted for a password, the keychain entry was deleted. 如果系统提示您输入密码,则会删除钥匙串条目。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/CHCH998/article/details/107406525

智能推荐

Docker 快速上手学习入门教程_docker菜鸟教程-程序员宅基地

文章浏览阅读2.5w次,点赞6次,收藏50次。官方解释是,docker 容器是机器上的沙盒进程,它与主机上的所有其他进程隔离。所以容器只是操作系统中被隔离开来的一个进程,所谓的容器化,其实也只是对操作系统进行欺骗的一种语法糖。_docker菜鸟教程

电脑技巧:Windows系统原版纯净软件必备的两个网站_msdn我告诉你-程序员宅基地

文章浏览阅读5.7k次,点赞3次,收藏14次。该如何避免的,今天小编给大家推荐两个下载Windows系统官方软件的资源网站,可以杜绝软件捆绑等行为。该站提供了丰富的Windows官方技术资源,比较重要的有MSDN技术资源文档库、官方工具和资源、应用程序、开发人员工具(Visual Studio 、SQLServer等等)、系统镜像、设计人员工具等。总的来说,这两个都是非常优秀的Windows系统镜像资源站,提供了丰富的Windows系统镜像资源,并且保证了资源的纯净和安全性,有需要的朋友可以去了解一下。这个非常实用的资源网站的创建者是国内的一个网友。_msdn我告诉你

vue2封装对话框el-dialog组件_<el-dialog 封装成组件 vue2-程序员宅基地

文章浏览阅读1.2k次。vue2封装对话框el-dialog组件_

MFC 文本框换行_c++ mfc同一框内输入二行怎么换行-程序员宅基地

文章浏览阅读4.7k次,点赞5次,收藏6次。MFC 文本框换行 标签: it mfc 文本框1.将Multiline属性设置为True2.换行是使用"\r\n" (宽字符串为L"\r\n")3.如果需要编辑并且按Enter键换行,还要将 Want Return 设置为 True4.如果需要垂直滚动条的话将Vertical Scroll属性设置为True,需要水平滚动条的话将Horizontal Scroll属性设_c++ mfc同一框内输入二行怎么换行

redis-desktop-manager无法连接redis-server的解决方法_redis-server doesn't support auth command or ismis-程序员宅基地

文章浏览阅读832次。检查Linux是否是否开启所需端口,默认为6379,若未打开,将其开启:以root用户执行iptables -I INPUT -p tcp --dport 6379 -j ACCEPT如果还是未能解决,修改redis.conf,修改主机地址:bind 192.168.85.**;然后使用该配置文件,重新启动Redis服务./redis-server redis.conf..._redis-server doesn't support auth command or ismisconfigured. try

实验四 数据选择器及其应用-程序员宅基地

文章浏览阅读4.9k次。济大数电实验报告_数据选择器及其应用

随便推点

灰色预测模型matlab_MATLAB实战|基于灰色预测河南省社会消费品零售总额预测-程序员宅基地

文章浏览阅读236次。1研究内容消费在生产中占据十分重要的地位,是生产的最终目的和动力,是保持省内经济稳定快速发展的核心要素。预测河南省社会消费品零售总额,是进行宏观经济调控和消费体制改变创新的基础,是河南省内人民对美好的全面和谐社会的追求的要求,保持河南省经济稳定和可持续发展具有重要意义。本文建立灰色预测模型,利用MATLAB软件,预测出2019年~2023年河南省社会消费品零售总额预测值分别为21881...._灰色预测模型用什么软件

log4qt-程序员宅基地

文章浏览阅读1.2k次。12.4-在Qt中使用Log4Qt输出Log文件,看这一篇就足够了一、为啥要使用第三方Log库,而不用平台自带的Log库二、Log4j系列库的功能介绍与基本概念三、Log4Qt库的基本介绍四、将Log4qt组装成为一个单独模块五、使用配置文件的方式配置Log4Qt六、使用代码的方式配置Log4Qt七、在Qt工程中引入Log4Qt库模块的方法八、获取示例中的源代码一、为啥要使用第三方Log库,而不用平台自带的Log库首先要说明的是,在平时开发和调试中开发平台自带的“打印输出”已经足够了。但_log4qt

100种思维模型之全局观思维模型-67_计算机中对于全局观的-程序员宅基地

文章浏览阅读786次。全局观思维模型,一个教我们由点到线,由线到面,再由面到体,不断的放大格局去思考问题的思维模型。_计算机中对于全局观的

线程间控制之CountDownLatch和CyclicBarrier使用介绍_countdownluach于cyclicbarrier的用法-程序员宅基地

文章浏览阅读330次。一、CountDownLatch介绍CountDownLatch采用减法计算;是一个同步辅助工具类和CyclicBarrier类功能类似,允许一个或多个线程等待,直到在其他线程中执行的一组操作完成。二、CountDownLatch俩种应用场景: 场景一:所有线程在等待开始信号(startSignal.await()),主流程发出开始信号通知,既执行startSignal.countDown()方法后;所有线程才开始执行;每个线程执行完发出做完信号,既执行do..._countdownluach于cyclicbarrier的用法

自动化监控系统Prometheus&Grafana_-自动化监控系统prometheus&grafana实战-程序员宅基地

文章浏览阅读508次。Prometheus 算是一个全能型选手,原生支持容器监控,当然监控传统应用也不是吃干饭的,所以就是容器和非容器他都支持,所有的监控系统都具备这个流程,_-自动化监控系统prometheus&grafana实战

React 组件封装之 Search 搜索_react search-程序员宅基地

文章浏览阅读4.7k次。输入关键字,可以通过键盘的搜索按钮完成搜索功能。_react search