问题
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取消了密码登陆推送,改用了访问令牌模式。
解决办法
- Log into GitHub with your username and password
- Navigate to your GitHub account settings
- Scroll down and click ‘Developer settings’ in the list of links to the left
- Click the Personal access tokens link
- Click the ‘Generate new token’ button
- Add a ‘Note’ to describe the tokens usage
- Set an expiration date for the GitHub personal access token
- Select the appropriate authentication scope
- Click the ‘Generate token’ button
然后页面上会生成一个随机字符串的秘密,你要复制保存下来,将它作为push的密码输入。注意:这个密码只显示一次,如果丢失,重复上述过程重新生成一个。
由于它太随机,无法人工记忆,因此可以使用git缓存下来
git config --global credential.helper 'cache --timeout=3600'
意义
- 避免了个人密码的泄漏
- 保证了github平台的安全性
- 避免了个人的弱密码