Github新安全措施:停止Git客户端账号密码登录的解决方案

简介: Github新安全措施:停止Git客户端账号密码登录的解决方案

太长不看:你以前怎么登录,现在就怎么登录,你以前怎么改密码,现在就怎么改,只不过要把用户名换成oauth2,密码换成你的令牌。



今年 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: unable to access 'https://github.com/<user>/<repo>/': The requested URL returned error: 403


解决方案就是使用访问令牌(AccessToken)。如果Git 客户端提示你需要登录 Github,账户输入oauth2,密码输入你的令牌。


如果你已经用账户密码登录过了。在推送的时候,不会提示你登录,而是直接报错。这种情况就需要打开~/.git-credentials文件,这个是Git客户端储存账号密码的地方。找到@github.com,把前面的用户名密码替换成oauth2:<token>,即大功告成。


   注:~代表用户目录,在 Windows 下,它是C:\Users\<username>\,在 Linux 下,它是/home/<username>/。不过不需要关心这个,因为 Bash 或者 PowerShell 会自动识别它。


注意,如果你的用户名密码在你仓库的远程 URL 里面,同样需要用git remote set-url来替换掉。


其实所有 Git 服务端都可以这样操作,这样支持权限隔离和细粒度控制,避免一码通密码,更加安全。



相关文章
|
1天前
|
存储 开发工具 git
|
5天前
|
开发工具 数据安全/隐私保护 C++
vs2019中同步到github上的用户名错误_控制面板和vs的git全局设置重新登录
vs2019中同步到github上的用户名错误_控制面板和vs的git全局设置重新登录
10 0
|
18天前
|
网络虚拟化
解决方案:Github Failed to connect to github.com port 443 after 21224 ms: Timed out
解决方案:Github Failed to connect to github.com port 443 after 21224 ms: Timed out
15 0
|
18天前
|
开发工具 数据安全/隐私保护 git
解决方案:Github Support for password authentication was removed on August 13, 2021.
解决方案:Github Support for password authentication was removed on August 13, 2021.
41 1
解决方案:Github Support for password authentication was removed on August 13, 2021.
|
28天前
|
Shell 开发工具 git
【Github】git bash将本地工程上传至github
【Github】git bash将本地工程上传至github
|
2月前
|
数据采集 Web App开发 Go
Python爬虫-模拟Github登录并获取个人信息
python爬虫案例,模拟登录Github
32 0
|
2月前
|
缓存 开发工具 数据安全/隐私保护
通过一篇文章带你玩转git和GitHub
在现代软件开发中,版本控制系统是不可或缺的工具。Git和Github是其中最受欢迎的组合。Git是一个开源的分布式版本控制系统,用于追踪代码的改动,而Github则是一个基于Git的代码托管平台,提供了代码托管、协作开发等功能。
82 2
通过一篇文章带你玩转git和GitHub
|
2月前
|
Linux 开发工具 git
Git与GitHub:解锁版本控制的魔法盒子
Git与GitHub:解锁版本控制的魔法盒子
31 1
|
3月前
|
Linux 开发工具 git
【开发专题_03】unable to access ‘https://github.com/deviantony/docker-elk.git/‘: Failed connect to github
【开发专题_03】unable to access ‘https://github.com/deviantony/docker-elk.git/‘: Failed connect to github
|
3月前
|
安全 Shell 网络安全
Git学习---Git快速入门、Git基础使用、Git进阶使用、Git服务器使用(IDEA集成GitHub、Gitee、GitLab)、GitHub Desktop客户端
Git学习---Git快速入门、Git基础使用、Git进阶使用、Git服务器使用(IDEA集成GitHub、Gitee、GitLab)、GitHub Desktop客户端
133 0