我试图通过Ubuntu实例上的OpenSSH禁用DHE密钥交换,从而减轻CVE-2002-20001的影响。
我知道这可以通过编辑/etc/ssh/sshd_config来实现。
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256
如何编辑这一行以禁用DHE密钥交换?这是否足以减轻该漏洞?我怎样才能确保威胁得到缓解?
发布于 2022-08-12 13:03:35
KexAlgorithms配置选项是正确的,但是您希望在行的开头使用-,如下所示:
KexAlgorithms -diffie-hellman-group1-sha1,diffie-hellman-group1-sha256,diffie-hellman-group14-sha1,diffie-hellman-group14-sha256,diffie-hellman-group15-sha256,diffie-hellman-group15-sha512,diffie-hellman-group16-sha256,diffie-hellman-group16-sha512,diffie-hellman-group17-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha512
因为:
如果指定的列表以“-”字符开头,那么指定的算法(包括通配符)将从默认集合中删除,而不是替换它们。
注意:您可以使用通配符,例如KexAlgorithms -diffie-hellman-group*
NOTE2:这不适用于较早版本的openssh,例如,在CentOS 7上,-不起作用,您必须明确说明您想要使用的算法:
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
还需要使用以下设置控制未经身份验证的连接的数量:
MaxStartups 10:30:100
PerSourceMaxStartups 1
PerSourceNetBlockSize 32:128
您可以使用以下命令找到可用的KexAlgorithms列表:
sudo sshd -T |grep kexalgorithms
在阻止Diffie-Hellman之前输出:
kexalgorithms curve25519-sha256、curve25519-sha256@libssh.org、ecdh-sha2-nistp 256、ecdh-sha2-nistp 384、ecdh-sha2-nistp384 521、diffie-hellman-group-exchange-sha256、diffie-hellman-group 16-sha512、diffie-hellman-group 18-sha512、diffie-hellman-group 14-sha256。
及之后:
kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp 256,ecdh-sha2-nistp 384,ecdh-sha2-nistp 521
或者你可以我们nmap:
nmap --script ssh2-enum-algos -sV -p 22 localhost
参考文献
发布于 2022-08-12 20:54:45
在Ubuntu20.04上,您可以通过在KexAlgorithms中设置配置项/etc/ssh/sshd_config.d/ssh-audit_hardening.conf来限制密钥交换算法。为了避免所有Diffie-Hellman组,您可以设置:
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org有一个(更新的) Python ssh-audit,它检查tcp套接字上的sshd。其硬化导轨建议将Diffie-Hellman集团的一个特定子集包括在内:
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256为验证:
pip install ssh-audit
ssh-audit -l warn -p <port> <hostname>https://security.stackexchange.com/questions/264078
复制相似问题