github Support for password authentication was removed

问题

2021年8月13号,github做了重大权限变更,不需要密码来进行身份验证,而是需要个人访问令牌。输入个人密码会提示如下错误:

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/xxx'

原因

github取消了密码登陆推送,改用了访问令牌模式。

解决办法

  1. Log into GitHub with your username and password
  2. Navigate to your GitHub account settings
  3. Scroll down and click ‘Developer settings’ in the list of links to the left
  4. Click the Personal access tokens link
  5. Click the ‘Generate new token’ button
  6. Add a ‘Note’ to describe the tokens usage
  7. Set an expiration date for the GitHub personal access token
  8. Select the appropriate authentication scope
  9. Click the ‘Generate token’ button

然后页面上会生成一个随机字符串的秘密,你要复制保存下来,将它作为push的密码输入。注意:这个密码只显示一次,如果丢失,重复上述过程重新生成一个。

由于它太随机,无法人工记忆,因此可以使用git缓存下来

git config --global credential.helper 'cache --timeout=3600'

意义

  1. 避免了个人密码的泄漏
  2. 保证了github平台的安全性
  3. 避免了个人的弱密码
上一篇:could not find included file 'Pods/Target Support Files/Pods-Runner/Pods-Runner.debu...


下一篇:Ubuntu12.4 换源 20210720