# Turn on post-quantum key exchange for SSH

Source: https://pq-scan.com/guide/ssh-pq-kex
Fixes: ssh-pq-kex-missing. Evidence: SSH negotiation lab, OpenSSH 10.0p2 (Debian 13) and 9.6p1 (Ubuntu 24.04), 6 December 2026; OpenSSH release notes.

## Why this matters

Someone who records SSH sessions today could decrypt them once a large quantum computer exists ("harvest now, decrypt later"). OpenSSH has used a post-quantum hybrid by default since 9.0 (2022) and ML-KEM by default since 10.0 (April 2025). If your server offers none, it is either old or has a `KexAlgorithms` line that removed them.

## The fix

### 1. Find old `KexAlgorithms` lines

```sh
sudo sshd -T | grep -E '^kexalgorithms'          # effective server config
grep -RIn 'KexAlgorithms' /etc/ssh 2>/dev/null
```

If a line lists only classical algorithms, delete it and let OpenSSH use its defaults. To drop one weak algorithm without losing the post-quantum defaults, use the `-` prefix instead of a full list:

```text title="/etc/ssh/sshd_config.d/10-kex.conf"
KexAlgorithms -diffie-hellman-group14-sha256
```

That syntax validated on OpenSSH 9.6p1 in our lab.

### 2. If your policy needs an explicit list, put the hybrids first

```text title="/etc/ssh/sshd_config.d/10-kex.conf (OpenSSH 10.x only)"
KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org
```

**Pitfall:** OpenSSH 9.x does not know `mlkem768x25519-sha256`. In our lab, Ubuntu 24.04 (OpenSSH 9.6p1) rejected the config and `sshd -t` exited with status 255, so `sshd` would not restart. Always validate before reloading:

```sh
sudo sshd -t && sudo systemctl reload ssh   # the unit is "sshd" on RHEL-family systems
```

### 3. Upgrade old OpenSSH

Ubuntu 24.04 (9.6p1) and Debian 12 (9.2p1) still get a post-quantum hybrid (sntrup761) by default, but not ML-KEM. Anything older than OpenSSH 9.0, or an embedded SSH server in network gear, needs an upgrade or a vendor answer.

## Verify

```sh
ssh -v -o BatchMode=yes user@your-server true 2>&1 | grep "kex: algorithm"
# debug1: kex: algorithm: mlkem768x25519-sha256
```

In SSH the **client's** order decides, so also check `~/.ssh/config` and automation for copied `KexAlgorithms` lines. Then rerun the SSH check on PQ Scan.

Verify after deploying: https://pq-scan.com/r/<your-domain>?fresh=1
