Git

Github推代码报 Support for password authentication was removed on August 13, 2021...错误

bridge
2022-01-30 / 0 评论 / 0 点赞 / 581 阅读 / 1,532 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2022-01-30,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

前言

好久没推往Github上推代码,最近
Github推代码报 Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.错误,详情提示如下

$ git push -u origin main
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/liguanqiao/leetcode-answer.git/'

大概意思是:

为什么要把密码换成token

下面是Github官方的解释: 近年来,GitHub 客户受益于 http://GitHub.com 的许多安全增强功能,例如双因素身份验证、登录警报、经过验证的设备、防止使用泄露密码和 WebAuthn 支持。 这些功能使攻击者更难获取在多个网站上重复使用的密码并使用它来尝试访问您的 GitHub 帐户。 尽管有这些改进,但由于历史原因,未启用双因素身份验证的客户仍能够仅使用其GitHub 用户名和密码继续对 Git 和 API 操作进行身份验证。

从 2021 年 8 月 13 日开始,我们将在对 Git 操作进行身份验证时不再接受帐户密码,并将要求使用基于令牌(token)的身份验证,例如个人访问令牌(针对开发人员)或 OAuth 或 GitHub 应用程序安装令牌(针对集成商) http://GitHub.com 上所有经过身份验证的 Git 操作。 您也可以继续在您喜欢的地方使用 SSH 密钥(如果你要使用ssh密钥可以参考)。

如何创建token

  1. 登录 Github;

  2. 在任何页面的右上角,单击您的个人资料照片,然后单击 Settings(设置)

  3. 在左侧边栏中,单击 Developer settings

  4. 在左侧边栏中,单击 Personal access tokens(个人访问令牌)

  5. 单击 Generate new token(生成新令牌)

  6. 给令牌一个描述性名称。

  7. 要使令牌过期,请选择 **Expiration(到期)**下拉菜单,然后单击默认值或使用日历选择器。

  8. 选择要授予此令牌的作用域或权限。 要使用令牌从命令行访问仓库,请选择 repo(仓库)

  9. 单击 Generate token(生成令牌)

1.得到一个生成好的TOKEN

如何使用TOKEN

  1. 已有项目推代码
git remote set-url origin https://<TOKEN>@github.com/<USERNAME>/<REPO>.git
  • :换成你自己得到的token
  • :是你自己github的用户名
  • :是你的仓库名称

2.克隆代码

$ git clone https://github.com/username/repo.git
Username: your_username
Password: your_token

参考: https://docs.github.com/cn/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token


以上是个人学习记录,如有不正确请多多包涵,也欢迎评论告诉我,谢谢~


0

评论区