我在GitHub上设置了2个因子身份验证。所以,一旦我在命令行工作并想要推送到我的仓库。我输入了我的用户名和密码,但是因为这样的错误而失败了
USERNAME@MYCOMPUTER:~/MyRepo$ git push
Username for 'https://github.com': GitHubUsername
Password for 'https://[email protected]': GitHubPassword
remote: Invalid username or password.
fatal: Authentication failed for '
https://github.com/GitHubUsername/MyRepo/'
所以,我读了这个post并得到了解决方案,我必须生成一个个人访问令牌来推送任何东西。很好,但我认为这是一个有点艰难的过程,因为首先我不记得大量令牌和第二次存储文本文件中的访问密钥是不安全的事情。
所以,如果有人可以提供一个简单的解决方案来推送我的回购而不禁用2FA,这将是非常好的。 - 谢谢!
不要使用Github而不是https,你应该在ssh上使用github。
https://help.github.com/en/articles/connecting-to-github-with-ssh
虽然https设置很简单,但设置ssh连接有点困难,这就是为什么https用作标准选项的原因。
如果要连接到github,则需要执行以下步骤:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
按照标准选项,设置密码。
Optionally configure an ssh-agentid_rsa
和id_rsa.pub
,.pub
文件包含公钥。
You can upload this key to Github进入设置,按“ssh键”,然后在那里添加密钥git remote
命令执行此操作:
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
通过执行git fetch
测试您的新设置,它应该询问您的ssh密钥密码,然后获取任何更新分支。