对于 CentOS/RHEL 7

有关更多信息,请查看手册页:

# man sshd_config

Ciphers

指定允许的密码。
多个密码必须以逗号分隔。
如果指定的值以“+”字符开头,则指定的密码将添加到默认集而不是替换它们。

支持的密码是:

3des-cbc
aes128-cbc
aes192-cbc
aes256-cbc
aes128-ctr
aes192-ctr
aes256-ctr
aes128-gcm@openssh.com
aes256-gcm@openssh.com
arcfour
arcfour128
arcfour256
blowfish-cbc
cast128-cbc
chacha20-poly1305@openssh.com

默认为:

chacha20-poly1305@openssh.com,
aes128-ctr,aes192-ctr,aes256-ctr,
aes128-gcm@openssh.com,aes256-gcm@openssh.com,
aes128-cbc,aes192-cbc,aes256-cbc,
blowfish-cbc,cast128-cbc,3des-cbc

可用密码列表也可以使用“ssh -Q 密码”获得。
例如:

# ssh -Q cipher
3des-cbc
blowfish-cbc
cast128-cbc
arcfour
arcfour128
arcfour256
aes128-cbc
aes192-cbc
aes256-cbc
rijndael-cbc@lysator.liu.se
aes128-ctr
aes192-ctr
aes256-ctr
aes128-gcm@openssh.com
aes256-gcm@openssh.com
chacha20-poly1305@openssh.com

为了禁用 CBC 密码,请使用除 CBC 密码外所需的密码更新 /etc/ssh/sshd_config。

禁用 CBC:

Ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com

更改完成后重新启动 sshd 服务。

# systemctl restart sshd

MAC

MACs 指定可用的 MAC(消息验证代码)算法。
MAC 算法用于数据完整性保护。
多个算法必须以逗号分隔。
如果指定的值以“+”字符开头,则指定的算法将添加到默认集而不是替换它们。

包含“-etm”的算法计算加密后的 MAC (encrypt-then-mac)。
这些被认为更安全,建议使用它们。
支持的 MAC 是:

hmac-md5
hmac-md5-96
hmac-ripemd160
hmac-sha1
hmac-sha1-96
hmac-sha2-256
hmac-sha2-512
umac-64@openssh.com
umac-128@openssh.com
hmac-md5-etm@openssh.com
hmac-md5-96-etm@openssh.com
hmac-ripemd160-etm@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
umac-64-etm@openssh.com
umac-128-etm@openssh.com

默认为:

umac-64-etm@openssh.com,umac-128-etm@openssh.com,
hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
hmac-sha1-etm@openssh.com,
umac-64@openssh.com,umac-128@openssh.com,
hmac-sha2-256,hmac-sha2-512,hmac-sha1,
hmac-sha1-etm@openssh.com

也可以使用“ssh -Q mac”获得可用 MAC 算法的列表。
例如:

# ssh -Q mac
hmac-sha1
hmac-sha1-96
hmac-sha2-256
hmac-sha2-512
hmac-md5
hmac-md5-96
hmac-ripemd160
hmac-ripemd160@openssh.com
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
hmac-ripemd160-etm@openssh.com
umac-64-etm@openssh.com
umac-128-etm@openssh.com

为了禁用 hmac-md5 MACs 算法,请使用除 ecample 的 hmac-md5 外所需的 Mac 更新 /etc/ssh/sshd_config:

MACs hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160

更改完成后重新启动 sshd 服务。

# systemctl restart sshd
www. On IT Road .com

对于 CentOS/RHEL 6

在 CentOS/RHEL 6 中,列出可用密码和 MAC 的命令是“sshd -T | grep ciphers | perl -pe 's/,/\n/g' | sort -u”和“nmap -vv -script=ssh2 -enum-algos.nse -p 22 本地主机”:

# sshd -T | grep ciphers | perl -pe 's/,/\n/g' | sort -u
nmap -vv --script=ssh2-enum-algos.nse -p 22 localhost

有关更多信息,请查看手册页:

# man sshd_config

密码

指定协议版本 2 允许的密码。
多个密码必须以逗号分隔。
支持的密码是:

3des-cbc
aes128-cbc
aes192-cbc
aes256-cbc
aes128-ctr
aes192-ctr
aes256-ctr
arcfour128
arcfour256
arcfour
blowfish-cbc
rijndael-cbc@lysator.liu.se
cast128-cbc

默认为:

aes128-ctr
aes192-ctr
aes256-ctr
arcfour256
arcfour128
aes128-cbc
3des-cbc
blowfish-cbc
cast128-cbc
aes192-cbc
aes256-cbc
arcfour
rijndael-cbc@lysator.liu.se

为了禁用 CBC 密码,请使用除 CBC 密码外所需的密码更新 /etc/ssh/sshd_config。

Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,arcfour

更改完成后重新启动 sshd 服务。

# service sshd restart

MAC

MACs 指定可用的 MAC(消息验证代码)算法。
MAC 算法在协议版本 2 中用于数据完整性保护。
多个算法必须以逗号分隔。
默认为:

hmac-md5,hmac-sha1,umac-64@openssh.com,
hmac-ripemd160,hmac-sha1-96,hmac-md5-96,
hmac-sha2-256,hmac-sha2-512,hmac-ripemd160@openssh.com

为了禁用 hmac-md5 MACs 算法,请使用除 ecample 的 hmac-md5 外所需的 Mac 更新 /etc/ssh/sshd_config:

MACs hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160@openssh.com

更改完成后重启 sshd 服务:

# service sshd restart
CentOS/RHEL 6 和 7 如何在 SSH 服务中禁用弱密码和不安全的 HMAC 算法

本文以CentOS/RHEL 6 和 7为示例,说明如何禁用 HMAC MD5 和 CBC 密码。

日期:2020-09-17 00:13:33 来源:oir作者:oir