背景
从 OpenSSH 9.0 开始,默认引入了混合后量子密钥交换算法 sntrup761x25519-sha512@openssh.com,用于抵御“先存储,后解密”(store now, decrypt later)攻击。OpenSSH 9.9 新增了 mlkem768x25519-sha256,并在 OpenSSH 10.0 中成为新默认。
在AlmaLinux 9的最新版本,openssh已经升级到9.9,理论上应当支持后量子密钥交换算法,但是连接时依旧存在警告:
WARNING: connection is not using a post-quantum key exchange algorithm.
This session may be vulnerable to "store now, decrypt later" attacks.
The server may need to be upgraded. See https://openssh.com/pq.html查看 sshd 实际生效的密钥交换算法
sshd -T | grep kexalgorithms会发现输出中只有传统 ECDH 和 DH 算法。这是因为系统级加密策略 crypto-policies 会覆盖 OpenSSH 的默认算法列表,默认情况下 不包含任何后量子算法
服务器环境
- AlmaLinux 9
- OpenSSH 9.9
- 已安装
crypto-policies(一般预装,如果没装显然也不会遇到这个问题了)以及crypto-policies-scripts(提供update-crypto-policies命令)
验证 OpenSSH 版本:
sshd -V确认已安装脚本包:
dnf install crypto-policies-scripts问题排查回顾
查看当前系统加密策略:
update-crypto-policies --show默认输出为
DEFAULT。查看 sshd 实际生效的密钥交换算法:
sshd -T | grep kexalgorithms输出中只有传统 ECDH 和 DH 算法,缺少
sntrup761x25519-sha512@openssh.com和mlkem768x25519-sha256。查看 crypto-policies 生成的 SSH 后端文件:
cat /etc/crypto-policies/back-ends/opensshserver.config | grep KexAlgorithms同样不包含后量子算法,这就是警告的根本原因。
解决方案:启用系统自带的 PQ 子策略
AlmaLinux 9的 crypto-policies 包中已经预置了一个 后量子(PQ)子策略模块,路径为:
ls /usr/share/crypto-policies/policies/modules/PQ.pmod那么要做的事情就很简单了,将 PQ 子策略附加到 DEFAULT 策略上(也可使用 FUTURE 等):
更新系统加密策略
update-crypto-policies --set DEFAULT:PQ重启服务
systemctl restart sshd验证生效
查看 sshd 当前提供的密钥交换算法:
sshd -T | grep kexalgorithms输出应包含
mlkem768x25519-sha256。查看 crypto-policies 后端文件确认:
cat /etc/crypto-policies/back-ends/opensshserver.config | grep KexAlgorithms同样应看到
mlkem768x25519-sha256。从客户端连接测试:
ssh your_server之前的 PQ 警告完全消失。