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 已经配置成功。

相关推荐
一只大袋鼠9 小时前
Git 进阶(二):分支管理、暂存栈、远程仓库与多人协作
java·开发语言·git
我叫张小白。16 小时前
Git 分支管理与团队协作
git
DogDaoDao17 小时前
Windows 下 Git 报错:`touch` 无法识别 —— 原因分析与 7 种解决方案(从入门到精通)
windows·git·程序员·npm·powershell·cmd·touch
caicai_xiaobai18 小时前
Ubuntu上Git安装步骤
linux·git·ubuntu
come1123419 小时前
git 区分是 Git 分支还是 worktree 路径名
git
憧憬成为java架构高手的小白19 小时前
git多人工作之个人规范使用【ai+个人理解】
git
CVer儿19 小时前
git简单操作
git
Andya_net20 小时前
Git | Git 核心命令深入解析:从原理到实战
大数据·git·elasticsearch
wh_xia_jun20 小时前
给小白的 Maven 命令行执行测试 完整指南
git·maven·intellij-idea
专业白嫖怪21 小时前
H3C UniServer R4950 G5 服务器压测实战:13根内存条24小时压力测试全流程
git