使用ssh拉取仓库代码时出现报错(确保自己正确配置了ssh)
- gitlab报错
no matching host key type found. Their offer: ssh-rsa,ssh-dss
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
- gitee报错
Permission denied(publickey)
使用ssh -vvvT git@gitlab.com命令可查看到自己OpenSSH的版本
原因gitlab和gitee使用golang.org/x/crypto/ssh来从public key中提取出指纹,以此兑换用户信息
而这个库目前(2021-10-12)还没有支持RSA-SHA2算法,因此会获取不到指纹,导致用户校验失败
解决方案下述三种方案任选其一即可
- 配置OpenSSH服务允许使用RSA-SHA1key
在 ~/.ssh/config 加上如下配置 Host gitee.com HostkeyAlgorithms +ssh-rsa PubkeyAcceptedAlgorithms +ssh-rsaPS:这种方式不需要更换ssh key,推荐Linux和windows git bash用户使用
- 换用其他算法生成ssh key
ssh-keygen -t ed25519 -C "your@example.email" 之后到Gitee重新添加公钥即可PS: 这种方式需要更换ssh key,推荐windows用户使用
- 暂时不要使用OpenSSH 8.8及以上版本
目前golang社区已经关注到了这一情况,且已经在推进对RSA-SHA2的支持,详情



