如题,使用 git 脚本 ssh 登录服务器报错:
Unable to negotiate with xx.xx.xx.xx port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

百度 no matching host key type found 找到一篇 教程 说主要原因是 OpenSSH 7.0 以后的版本不再支持 ssh-dss (DSA)算法。

方法一:执行 ssh 指令时增加参数

ssh -oHostKeyAlgorithms=+ssh-dss user@legacyhost

user@legacyhost 替换成自己的服务器登录名及登录地址

方法二:修改 ssh 配置

添加 HostKeyAlgorithms +ssh-dss 到配置 ~/.ssh/config(没有就新建):

Host somehost.example.org
    HostKeyAlgorithms +ssh-dss

其中的 somehost.example.org 替换成自己的域名或IP。

优先选择第二种方法,因为之后可以不用每次连接都增加那样的参数。