如何禁用弱 HMAC 算法?在 ssh_config 或 sshd_config 文件中找不到

roc*_*ine 7 ssh encryption openssh sshd

漏洞扫描显示,在 Debian 10 系统中,使用了不安全的 MAC 算法:umac-64-etm@openssh.com、hmac-sha1-etm@openssh.com、umac-64@openssh.com、hmac-sha1

当我这样做时ssh -Q mac,我得到以下结果:

hmac-sha1
hmac-sha1-96
hmac-sha2-256
hmac-sha2-512
hmac-md5
hmac-md5-96
umac-64@openssh.com
umac-128@openssh.com
hmac-sha1-etm@openssh.com
hmac-sha1-96-etm@openssh.com
hmac-sha2-256-etm@openssh.com
hmac-sha2-512-etm@openssh.com
hmac-md5-etm@openssh.com
hmac-md5-96-etm@openssh.com
umac-64-etm@openssh.com
umac-128-etm@openssh.com
Run Code Online (Sandbox Code Playgroud)

文件中/etc/ssh/ssh_config有一行被注释掉:

#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com
Run Code Online (Sandbox Code Playgroud)

文件中没有提及 umac-64-etm 或 hmac-sha1-etm。其中/etc/ssh/sshd_config根本没有 MAC 关键字。如何禁用这些弱 HMAC?

Gil*_*il' 10

支持的 MAC 算法列表由MACsinssh_config和 in 中的选项确定sshd_config。如果不存在,则使用默认值。如果您想要更改默认值,请编辑现有条目或添加一个(如果不存在)。例如:

MACs hmac-sha2-256,hmac-sha2-512,umac-128@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com
Run Code Online (Sandbox Code Playgroud)

OpenSSH 的最新版本(Debian 10也足够新)还允许差异化规范,例如禁用所有短 MAC 和基于 MD5 或 SHA-1 的 MAC:

MACs -*md5*,*sha1,*sha1-*,*-64,*-96
Run Code Online (Sandbox Code Playgroud)

请注意,默认算法实际上都不是不安全的。64 位 MAC 对于离线使用而言非常弱,但对于仅在一次连接内有效的网络消息来说是可以接受的,在任何人都可以破坏 64 位 MAC 之前,它就会超时。(这表明它们仍然在 OpenSSH 的默认列表中,尽管 OpenSSH 在安全方面非常积极主动。)MD5 和 SHA1 的弱点使得它们作为哈希值不安全,但 HMAC 构造并不关心这些弱点。我建议至少保留hmac-sha1与旧系统的互操作性,除非您绝对需要出于合规性而禁用它(这与合规性有关,而不是与安全性有关)。

  • 这个解决方案对我不起作用。我在 sshd_config 文件中添加了这两行:“MACs hmac-sha2-256,hmac-sha2-512,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com”和“ MACs -*md5*,*sha1,*sha1-*,*-64,*-96" 但 stll "ssh -Q mac" 在重新启动服务后显示它们。另外,“ssh -o MACs=hmac-sha1 u@h”也可以轻松连接。有什么建议吗? (2认同)