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

相关推荐
要站在顶端2 小时前
克隆大型仓库卡住(7%每次就卡住了)
git
五月底_3 小时前
上传大量文件到github repo
git·github
rannn_11111 小时前
【Git教程】概述、常用命令、Git-IDEA集成
java·git·后端·intellij-idea
春日见13 小时前
虚拟机上由于网络问题无法正常git clone
linux·服务器·网络·人工智能·git·ubuntu·debug
冉佳驹13 小时前
Linux ——— Git的核心操作流程、进程状态及环境变量相关知识
linux·git·进程·环境变量·进程状态·fork
cherry有点甜·13 小时前
【git】git为什么会出现双向合并
git
笨鸟不是菜鸟15 小时前
gitignore文件如何添加忽略文件或文件夹
git
灰色人生qwer15 小时前
git add . 添加超长文件名报错了怎么办?
git·python·elasticsearch
星海拾遗1 天前
git rebase记录
大数据·git·elasticsearch
ljh5746491191 天前
PhpStorm 2022.3 版本中,修改使用 Git 提交时看到弹出式的对话框模式
ide·git·php·phpstorm