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

相关推荐
小龙1 天前
【Git 报错解决】本地无有效提交无法推送(`src refspec main does not match any`)
git·github·报错
小扶苏1 天前
删除git全局账号信息并设置成新的账号密码命令
git
Greg_Zhong1 天前
Git创建任务分支进行开发,最后合并主分支master【纯git命令执行过程】阐述
git
眯眼因为很困啦1 天前
GitHub Fork 协作完整流程
前端·git·前端工程化
AlexDeng2 天前
Git 中模糊搜索分支名称并创建本地跟踪分支
git
jxm_csdn2 天前
递归工程工厂:Claude Code + Git Worktrees + Tilix/Tmux 的“AI分身”编码团队
人工智能·git
码咔吧咔2 天前
Git 中 pull.rebase = true 的作用与设置方法详解
git
郑州光合科技余经理2 天前
开发实战:海外版同城o2o生活服务平台核心模块设计
开发语言·git·python·架构·uni-app·生活·智慧城市
我是海飞2 天前
Git 本地仓库推送到远程空仓库指南
大数据·git·elasticsearch
记得开心一点嘛2 天前
如何去使用git进行协同开发?
git