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 [email protected]: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 "[email protected]"

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

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

然后运行下面命令验证

shell 复制代码
$ ssh -T [email protected]

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

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

相关推荐
一直在学习的小白~8 小时前
Sourcetree安装使用的详细教程
git
陈苏同学10 小时前
从 Git 到 GitHub - 使用 Git 进行版本控制 - Git 常用命令
git·github
影子240110 小时前
git项目迁移,包括所有的提交记录和分支 gitlab迁移到gitblit
git·gitlab·git迁移
laimaxgg15 小时前
Git撤销修改
git
象骑士Hack18 小时前
Xterminal(或 X Terminal)通常指一类现代化的终端工具 工具介绍
git
新时代牛马18 小时前
git处理浅克隆
git
学习2年半19 小时前
git相关
git
极小狐19 小时前
如何减少极狐GitLab 容器镜像库存储?
运维·git·rpc·kubernetes·ssh·gitlab·terraform
C.er1 天前
Git回顾
git
极小狐1 天前
如何使用极狐GitLab 软件包仓库功能托管 ruby?
开发语言·数据库·人工智能·git·机器学习·gitlab·ruby