解决Error:You‘re using an RSA key with SHA-1, which is no longer allowed

一、问题

在微信开发者工具中,推送代码时发生错误Error:You‘re using an RSA key with SHA-1, which is no longer allowed......
奇怪的是命令行可以正常push:
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
原因:因为生成密钥的RSA算法,由于安全性原因,现在已经不允许使用了。
参考Improving Git protocol security on GitHub
部分节选

Improving Git protocol security on GitHub We’re changing which keys
are supported in SSH and removing unencrypted Git protocol. Only users
connecting via SSH or git:// will be affected. If your Git remotes
start with https://, nothing in this post will affect you. If you’re
an SSH user, read on for the details and timeline.

译文:
改进GitHub上的Git协议安全性
我们正在更改SSH中支持的密钥,并删除未加密的Git协议。只有通过SSH或git://连接的用户才会受到影响。如果您的Git远程以https://开头,那么本文中的任何内容都不会影响您。如果您是SSH用户,请继续阅读以了解详细信息和时间表。

二、解决

//生成一个GitHub用的SSH-Key。
ssh-keygen -t rsa -C ‘123456@qq.com’ -f ~/.ssh/github_id_rsa

ssh-keygen命令中的rsa一种生成密钥的算法,也可以根据需求更换其他算法生成 ssh key
例如ssh-keygen -t ed25519 -C "your@example.email" 这里使用的就是ed25519算法, 之后到对应平台重新添加公钥即可

2.1 步骤与命令

因为生成密钥的RSA算法,由于安全性原因,现在已经不允许使用了。这里我们采用ECDSA算法来生成密钥。

//djc@qq.com"为示例邮箱,需要修改成自己个人注册并使用GitHub的主邮箱。
1、生成ECDSA密钥-二选一即可
//第一种:这种默认生成的公私钥名称为id_ecdsa.pub与id_ecdsa
//执行命令之后需要连续按3次回车键
//默认生成的公私钥id_ecdsa.pub与id_ecdsa文件位于C:\Users\JIACHENGER\.ssh目录下
ssh-keygen -t ecdsa -b 521 -C "djc@qq.com"

//第二种:这种指定了公私钥名称为github_id_ecdsa.pub与github_id_ecdsa 【我采用这种】
//执行命令之后需要连续按3次回车键
//生成的公私钥github_id_ecdsa.pub与github_id_ecdsa文件位于C:\Users\JIACHENGER\.ssh目录下
ssh-keygen -t ecdsa -b 521 -C "djc@qq.com"  -f ~/.ssh/github_id_ecdsa 

公私钥路径
C:\Users\JIACHENGER\.ssh\github_id_ecdsa 私钥路径
C:\Users\JIACHENGER\.ssh\github_id_ecdsa.pub  公钥路径


2、配置config中私钥的位置(如果同时配置了多个代码托管平台)
//将IdentityFile ~/.ssh/github_id_rsa 修改为 IdentityFile ~/.ssh/github_id_ecdsa
//表示不再使用RSA算法生成的key,而采用ecdsa算法生成的key。

3、在GitHub中设置公钥。
选择SSH and GPG keys,然后点击New SSH key ,将github_id_ecdsa.pub中的内容复制粘贴后保存。

4、检测
ssh -T git@github.com

5、再次使用微信开发者工具提交

2.2 步骤截图

1、生成ECDSA密钥:
在这里插入图片描述
在这里插入图片描述
2、配置config中私钥的位置(如果同时配置了多个代码托管平台):
#表示注释,不起作用,可删除。

##2023-12-6 18:42:42 配置使用刚刚生成ECDSA算法密钥  将 IdentityFile ~/.ssh/github_id_rsa 修改为    IdentityFile ~/.ssh/github_id_ecdsa

User git
 Host github.com    UpdateHostKeys yes
   Hostname github.com
   PreferredAuthentications publickey
  #IdentityFile ~/.ssh/github_id_rsa    2023-12-6 18:53:56注释此行表示失效,同时启用下面一行
   IdentityFile ~/.ssh/github_id_ecdsa

3、在GitHub中设置公钥
选择SSH and GPG keys,然后点击New SSH key ,将github_id_ecdsa.pub中的内容复制粘贴,输入GitHub账户正确的密码,确认权限后才能成功保存。
成功添加公钥github_id_ecdsa.pub完成后,ssh-keygen -t ecdsa -b 521 -C “djc@qq.com” -f ~/.ssh/github_id_ecdsa 中配置的邮箱djc@qq.com会收到相关提示,通知你A new SSH authentication public key was added to your account

过程可参考我这篇文章GitHub&Gitee&Gitlab&极狐(JihuLab)同时生成并配置和检测不同SSH公私钥详细过程
中的 3.2 GitHub中配置公钥github_id_rsa.pub

4、检测 ssh -T git@github.com
在这里插入图片描述
在这里插入图片描述
5、再次使用微信开发者工具提交
成功在微信开发者工具中,推送push项目刚刚所做的提交到GitHub。
在这里插入图片描述
GitHub
在这里插入图片描述

三、相关参考

Improving Git protocol security on GitHub
生成新的 SSH 密钥并将其添加到 ssh-agent
GitHub&Gitee&Gitlab&极狐(JihuLab)同时生成并配置和检测不同SSH公私钥详细过程
git 出现 ERROR: You‘re using an RSA key with SHA-1, which is no longer allowed
GitHub推送报错:You‘re using an RSA key with SHA-1, which is no longer allowed

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值