由于我想保护我的 ssh 连接,我设置了一些全局密码套件选项来限制使用的算法集。但是最近我遇到了一个不支持其中一些算法的服务器。因此,我需要有选择地为客户端(我的系统)配置中的特定主机记录启用已弃用的算法。
我发现选项覆盖没有按我预期的那样工作。让我们为 github 举一个最小的(非)工作示例:
HostKeyAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp256
Host github
HostKeyAlgorithms ssh-rsa
Hostname github.com
Port 22
User git
PubkeyAuthentication yes
IdentityFile ~/.ssh/some-filename-here
Run Code Online (Sandbox Code Playgroud)
有了这个,我收到以下错误(HostKeyAlgorithms
根本没有被覆盖):
debug1: /home/username/.ssh/config line 14: Applying options for github
<...>
debug2: kex_parse_kexinit: ssh-ed25519-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp256
<...>
Unable to negotiate with 192.30.252.130: no matching host key type found. Their offer: ssh-dss,ssh-rsa
Run Code Online (Sandbox Code Playgroud)
它同样不适用于PubkeyAuthentication no
在主机配置中覆盖的全局选项。
此外,这match
也无济于事:
match host github
HostKeyAlgorithms ssh-rsa
Run Code Online (Sandbox Code Playgroud)
那么,有没有办法选择性地重新定义这些选项?
注意:我在 gentoo 上使用 openssh-7.1_p2-r1。