如何禁用OpenSSH(CBC)加密模式防止信息泄露

2021-10-08  本文已影响0人  风静花犹落

描述

OpenSSH是一种开放源码的SSH协议的实现,初始版本用于OpenBSD平台,现在已经被移植到多种Unix/Linux类操作系统下。如果配置为CBC模式的话,OpenSSH没有正确地处理分组密码算法加密的SSH会话中所出现的错误,导致可能泄露密文中任意块最多32位纯文本。在以标准配置使用OpenSSH时,攻击者恢复32位纯文本的成功概率为2^{-18}, 此外另一种攻击变种恢复14位纯文本的成功概率为2^{-14}。

方案

编辑ssh配置文件

vim /etc/ssh/sshd_config

# Ciphers and keying下或者文件的末尾 添加下文

# Ciphers and keying
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,arcfour

重启SSH服务使配置生效

systemctl restart sshd

校验

使用SSH针对CBC分组类型的加密算法进行检查

ssh -vv -oCiphers=aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc 127.0.0.1

屏幕打印的日志的最后一行:

....

no matching cipher found: client aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc server aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,arcfour

出现 no matching cipher found: client aes128-cbc,3des-cbc … 说明配置生效。(此时的SSH登录并未成功)

文档

man sshd_config

查看默认SSH支持加密算法分组类型

     Ciphers
             Specifies the ciphers allowed.  Multiple ciphers must be comma-separated.  If the specified value begins with a ‘+’ character, then the specified ciphers will be appended to the default set instead of replacing them.

             The supported ciphers are:

                   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

             The default is:

                   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

             The list of available ciphers may also be obtained using "ssh -Q cipher".

上一篇 下一篇

猜你喜欢

热点阅读