问题:如何在 CentOS/RHEL 8 中禁用 SSH 服务中的弱密码和不安全 HMAC 算法?
为了在 CentOS/RHEL 8 的 ssh 服务中禁用弱密码和不安全的 HMAC 算法,请按照以下说明操作:
- 编辑 /etc/sysconfig/sshd 并取消注释 CRYPTO_POLICY 行:
将
# CRYPTO_POLICY=[Oroirnal value]
修改为:
CRYPTO_POLICY=[New value]
- 确保已将正确的密码、MAC 和 KexAlgorithms 添加到 /etc/ssh/sshd_config 文件中。
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256 Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
- 重启sshd服务:
# systemctl restart sshd
- 要测试是否启用了弱 CBC 密码,请运行以下命令:
# ssh -vv -oCiphers=3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc [@IP of your Server]
如果成功,它会提示输入密码。
这意味着启用了弱密码。
如果失败,我们应该收到如下消息:
Unable to negotiate with port 22: no matching cipher found. Their offer: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr
这意味着缓解措施正常工作。
- 要测试是否启用了弱 HMAC 算法,请运行以下命令:
# ssh -vv -oMACs=hmac-md5,hmac-md5-96,hmac-sha1,hmac-sha1-96,hmac-md5-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha1-96-etm@openssh.com,umac-64-etm@openssh.com [@IP of your Server]
日期:2020-09-17 00:13:33 来源:oir作者:oir