Skip to content
01.版本控制»01.Git»99.常见问题»LV010-秘钥问题.md

LV010-秘钥问题

一、问题描述

ubuntu16.04.7中使用git clone的时候出现以下问题:

shell
正克隆到 'uboot-imx'...
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.

二、问题排查

遇到这个问题后,我做了以下处理,排查问题所在:

(1)删除之前的ssh私钥和公钥,重新添加公钥到github

在报错信息中提示:

shell
Please use a newer client or a different key type.

故尝试重新生成公钥,但是结果是没有解决问题。

三、问题解决

网上查阅了很多资料,查阅到官方文档有这么一部分:Improving Git protocol security on GitHub | The GitHub Blog

从这部分文档可以了解到githubSSH密钥做了升级,原来的SHA-1等一些已经不支持了。所以我们可以生成新的Ed25519密钥对:

shell
rm ~/.ssh/id_rsa*
ssh-keygen -t ed25519 -C "user's github email address"

然后将重新生成的公钥添加到github,另外注意winGit安装目录下的etc\ssh\ssh_config文件或者Ubuntu~/.ssh/config文件也需要修改:

markdown
Host github.com
User <user Email>
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_ed25519
Port 443

上边的User后边要写上自己绑定的在Git中使用的邮箱。然后git就可以正常使用了。

莫道桑榆晚 为霞尚满天.