Print

解决Support for password authentication 报错问题


作者: 文章来源:

本文原地址:https://www.mimiwuqi.com/webqianduan/196432.html

好久没有往 Github 提交代码了,今天偶然提交代码的时候给报了一个remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.的错误,错误提示如下。

(yolov4) shl@zhihui-mint:~/shl_res/5_new_project/Yolov4_DeepSocial$ git push origin master
Username for 'https://github.com': wangda
Password for 'https://wangda@github.com': 
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: unable to access 'https://github.com/wangda/Yolov4_DeepSocial.git/': The requested URL returned error: 403
(yolov4) shl@zhihui-mint:~/shl_res/5_new_project/Yolov4_DeepSocial$ 

大概意思就是,你原先的密码凭证从 2021 年 8 月 13 日开始就不能用了,必须使用个人访问令牌(personal access token),就是把你的密码替换成 token!

为什么要把密码换成 token

下面是 Github 官方的解释:

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

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

如果你要使用 ssh 密钥可以参考

修改为 token 的好处:

令牌(token)与基于密码的身份验证相比,令牌提供了许多安全优势:

如何生成 token

1,打开 Github,在个人设置页面,找到【Setting】,然后打开找到【Devloper Settting】,如下图。

解决Support for password authentication 报错问题 1

生成 token 后,记得把你的 token 保存下来,以便进行后面的操作。把 token 直接添加远程仓库链接中,这样就可以避免同一个仓库每次提交代码都要输入 token 了。

git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git

示例如下:

git remote set-url origin https://ghp_LJGJUevVou3FrISMkfanTYRL7VgbFN0Agi7j@github.com/wangda/Yolov4_DeepSocial.git/

更多 建站教程 请访问 https://www.mimiwuqi.com/webqianduan/