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

相关推荐
xuxie9917 小时前
GIT版本管理
git
茶栀(*´I`*)17 小时前
Git从零开始操作清单
git
李永奉20 小时前
Git和GitHub-Git 管理的版本数据到底保存在哪个文件夹里?
git·github
Mortalbreeze20 小时前
Git 基础篇(二):本地仓库管理与常用操作
git
武昌库里写JAVA3 天前
SpringBoot+Vue 项目介绍
java·javascript·git·sql·ai
Hvitur5 天前
Git - 多分支合并
git·github
考虑考虑6 天前
git刷新远程分支列表
git·后端·gitlab
AI大模型-小华6 天前
Codex 自动测试怎么用?从生成测试用例到修复失败用例
git·测试用例·ai编程·软件开发·codex·chatgpt pro·codex cli
七分辣度7 天前
GitHub/Git 常用命令及使用场景
git·github
慧都小项8 天前
MyEclipse Inline Diff 实用指南:逐处核对 AI 修改再提交
git·ai编程·myeclipse·java 代码审查·ai 代码修改