Git命令报错ERROR: You‘re using an RSA key with SHA-1, which is no longer allowed.

在Windows上使用Git命令clone项目的时候报错"ERROR: You're using an RSA key with SHA-1, which is no longer allowed.",具体错误如下:

shell 复制代码
$ git clone git@github.com:xxx/xxx.git
Cloning into 'xxx'...
ERROR: You're using an RSA key with SHA-1, which is no longer allowed.
Please use a newer client or a different key type.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

错误原因是github现在不再支持SHA-1的加密方式了。因此需要将SHA-1的加密方式修改为ECDSA的方式。

执行下面的命令生成ECDSA密钥

shell 复制代码
ssh-keygen -t ecdsa -b 521 -C "xxx@hotmail.com"

命令执行完成后会在~/.ssh目录中产生两个文件id_ecdsa和id_ecdsa.pub,分别为私钥和公钥。

我们将id_ecdsa.pub文件内容复制到 github -> Settings -> SSH and GPG keys -> New SSH Key

然后运行下面命令验证

shell 复制代码
$ ssh -T git@github.com

Hi kongxx! You've successfully authenticated, but GitHub does not provide shell access.

如果出现上面的提示,说明 ssh key 已经配置成功。

相关推荐
代码or搬砖11 小时前
Git学习笔记(三)
笔记·git·学习
虾说羊14 小时前
git连接远程仓库并拉去推送以及克隆命令
git
IT~狂男16 小时前
GIT 实战命令操作大全,代码变动,推动,修改备注,撤销(篇幅一)
git
前端拿破轮16 小时前
从0到1搭一个monorepo项目(一)
前端·javascript·git
消失的旧时光-194317 小时前
git的 Rebase
git
风禾万里1 天前
Git怎么管理软件版本(代码,模型,配置等)
git
默默coding的程序猿1 天前
3.git的分支携带问题是什么?怎么解决?
java·git·python·svn·gitee·github·intellij-idea
天地人-神君1 天前
将.idea取消git托管
java·git·intellij-idea
Zach_yuan1 天前
版本控制器Git
linux·git
唐青枫2 天前
Git 提交时神秘的 create mode 100644 到底是什么?一文告诉你答案!
git