Git error: Unable to negotiate with XX.XX.XXX.XXX : no matching host key type found . their offer: ssh-dss

Git error: Unable to negotiate with XX.XX.XXX.XXX : no matching host key type found . their offer: ssh-dss

我正在尝试连接到可通过我的 VPN 运行的存储库。我下载了 Git,当我尝试克隆存储库时,我收到此消息:

Unable to negotiate with XX.XX.XXX.XXX : no matching host key type found . their offer: ssh-dss

有什么我遗漏的吗?

您正在尝试通过 ssh 协议进行克隆。另一端的 ssh 服务器要求您使用 dss 密钥身份验证,但您 git 使用的 ssh 客户端无法访问,可能是因为您尚未创建。

如何创建密钥取决于您使用的 ssh 客户端和操作系统。

当您创建密钥时,您实际上是在创建一个密钥对,其中包含一个私钥和一个 public 密钥。服务器必须知道 public 密钥才能对您进行身份验证。

如何将 public 密钥添加到服务器 ssh-server,取决于所使用的 ssh 服务器(或包装 ssh 服务器的 git 托管软件)。

我发现了问题,新的 OpenSSH 版本禁用了 ssh-dss (DSA) public 密钥算法。 DSA 被认为太弱,OpenSSH 社区建议不要使用它。

如果您看到类似这样的错误:

Unable to negotiate with 10.96.8.72: no matching host key type found. Their offer: ssh-dss

...然后您必须通过编辑 ~/.ssh/config 文件以添加以下行来重新启用 DSA 密钥:

HostkeyAlgorithms +ssh-dss

如果 ~/.ssh/config 文件不存在,您可能需要创建它。

创建文件后,您必须限制访问权限:

chmod 600 ~/.ssh/config

然后进行克隆。 那应该工作得很好!