no matching host key type found. Their offer: ssh-rsa,ssh-dss问题解决

最近在克隆git项目时,遇到如下问题:

    ~/project  git clone [email protected]:xxx/xxx.git                                                                                                                                                         ✔ 
正克隆到 'xxx'...
Unable to negotiate with xxx.xxx.xxx.xxx port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
fatal: 无法读取远程仓库。

请确认您有正确的访问权限并且仓库存在。

解决方法如下:

~/.ssh目录下,创建config文件,文件内容为:

注意将xxx.com改为实际的地址

Host xxx.com
        HostKeyAlgorithms ssh-rsa
        PubkeyAcceptedKeyTypes ssh-rsa