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. 避免了个人的弱密码
GitHub在2021年8月13日后不再支持使用密码进行身份验证。取而代之的是使用访问令牌(token)进行身份验证。为了生成一个访问令牌,您需要在GitHub的设置中选择权限和令牌选项,然后选择一个有效期限,并勾选所需的权限(如repo)。最后,点击生成令牌并记得保存。 在您准备上传项目到GitHub之前,您需要在所要上传项目的目录中打开命令行界面。然后,按照以下步骤进行操作: 1. 输入命令 `echo "# <项目名称>" >> README.md`,这将创建一个新的README文件。 2. 输入命令 `git init`,这将初始化一个新的Git仓库。 3. 输入命令 `git add README.md`,这将将README文件添加到Git的暂存区。 4. 输入命令 `git commit -m "first commit"`,这将提交您的第一个提交以保存更改。 5. 输入命令 `git branch -M main`,这将创建一个名为main的主分支。 6. 输入命令 `git remote add origin https://github.com/<您的用户名>/<项目名称>.git`,这将将您的本地仓库与GitHub远程仓库关联起来。 7. 输入命令 `git push -u origin main`,这将将您的本地仓库的更改推送到GitHub远程仓库。 通过按照以上步骤,您将能够使用访问令牌进行身份验证,并成功地上传您的项目到GitHub。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [remote: Support for password authentication was removed on August 13, 2021. Please use a personal ac](https://blog.csdn.net/FIVE9523/article/details/122374992)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值