git提交代码时报错:
git 报错
Unable to negotiate with 106.52.160.162 port 22: no matching host key type found. Their offer: ssh-rsa
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
原因:
是Git找不到支持的密钥交换方法,因为新版Openssh中认为SHA1这种hash散列算法过于薄弱,已经不再支持,所以需要手动去允许对于SHA1的支持 。
解决办法:
1、MacOS、Linux,在生成公钥的~/.ssh文件夹下,新建一个config文件(config文件没有后缀)。
2、Windows 文件夹在当前用户下 ~/.ssh(如下图所示)比如我的用户目录
新建一个config文档,config文件是添加代码:
Host *
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
保存,然后重新提交代码,成功。
返回项目,文件内容有增加了,不在是空项目文件
总结: