首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenSSH禁用Diffie-Hellman (DHE)密钥交换

OpenSSH禁用Diffie-Hellman (DHE)密钥交换
EN

Security用户
提问于 2022-08-12 07:16:44
回答 2查看 2.4K关注 0票数 2

我试图通过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密钥交换?这是否足以减轻该漏洞?我怎样才能确保威胁得到缓解?

EN

回答 2

Security用户

发布于 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

参考文献

加热器git回购

sshd_配置KexAlgorithms

票数 4
EN

Security用户

发布于 2022-08-12 20:54:45

在Ubuntu20.04上,您可以通过在KexAlgorithms中设置配置项/etc/ssh/sshd_config.d/ssh-audit_hardening.conf来限制密钥交换算法。为了避免所有Diffie-Hellman组,您可以设置:

代码语言:javascript
复制
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org

有一个(更新的) Python ssh-audit,它检查tcp套接字上的sshd。其硬化导轨建议将Diffie-Hellman集团的一个特定子集包括在内:

代码语言:javascript
复制
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256

为验证:

代码语言:javascript
复制
pip install ssh-audit
ssh-audit -l warn -p <port> <hostname>
票数 2
EN
页面原文内容由Security提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://security.stackexchange.com/questions/264078

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档