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

相关推荐
chao_78928 分钟前
双设备全栈开发最佳实践[mac系统]
git·python·macos·docker·vue·全栈
大卫小东(Sheldon)16 小时前
GIM 2.0 发布:真正让 AI 提交消息可定制、可控、可项目级优化
git·rust·gim
知识即是力量ol19 小时前
研发实战:Git 规范化开发全流程指南
git·gitee·github
我是一只代码狗19 小时前
idea创建分支
git
知识即是力量ol21 小时前
Git 快速入门 (实习生视角)
git·gitee·github
Dontla21 小时前
Git撤销上一次提交(撤销提交,Git回退提交)git reset、git revert
git
wdfk_prog1 天前
解决 `git cherry-pick` 引入大量新文件的问题
大数据·git·elasticsearch
fu的博客1 天前
Git从删库到跑路
git·gitee·github
要加油哦~1 天前
git 报错 | husky - pre-commit hook exited with code 1 解决
git
知识即是力量ol1 天前
Git 实战指南:从分支管理到冲突解决
git·github·源代码管理