ssh - 错误的配置选项:KeyAlgorithms

ssh - Bad configuration option: KeyAlgorithms

我已经启动了一个 gerrit 服务器。当我尝试通过 ssh 访问它时,我得到:

Unable to negotiate with 127.0.0.1 port 29418: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

由于已弃用,因此需要手动启用 (http://www.openssh.com/legacy.html):

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 username@localhost -p 29418

这很好用。现在我想 git clone,但需要通过 git 将 KexAlgorithms 选项传递给 ssh。一种解决方案是add the option to ~/.ssh/config。这是我添加的:

Host localhost
    KeyAlgorithms +diffie-hellman-group1-sha1

问题是我收到以下错误:

/home/username/.ssh/config: line 6: Bad configuration option: keyalgorithms

有一个 HostKeyAlgorithms 选项在那里工作但抱怨 Bad key types '+diffie-hellman-group1-sha1'。我应该如何配置 git/ssh 以连接到 gerrit?

你在配置中放置了与命令行不同的选项。应该是

Host localhost
    KexAlgorithms +diffie-hellman-group1-sha1

KexAlgorithms 不是 HostKeyAlgorithms。它们是完全不同的选项,具有不同的价值,服务于不同的目的。