346 views
SSH Post-Quantum algo transition quick guide === # OpenSSH: post-quantum migration *Updated: 2026-12-04 (revision 7). Target: OpenSSH ≥ 10.6p2, with current security updates.* This guide covers Linux servers using ordinary OpenSSH public-key authentication. Protect all three components: key exchange (KEX), host authentication and user authentication. > [!info] Why migrate authentication now? > The [NSA advisory](https://www.nsa.gov/Press-Room/Press-Releases-Statements/Press-Release-View/Article/4662430/nsa-advises-immediate-transition-to-post-quantum-cryptography-to-protect-nation/) (Dec 2, 2026) flags EdDSA and 256-bit ECC in the context of AI-assisted cryptanalysis. [Filippo Valsorda](https://words.filippo.io/nsa-advisory/) suspects a classical weakness or break; the [joint government statement](https://www.nsa.gov/Press-Room/Press-Releases-Statements/Press-Release-View/Article/4662453/joint-statement-from-oncd-nsa-and-cisa-on-recent-advances-in-cryptographic-and/) assesses no immediate, widespread threat. A practical ECC break has not been publicly established. This guide assumes ECC signatures may be forgeable: PQ KEX protects against retrospective decryption; hybrid (or interim RSA) signatures address impersonation. > [!important] Before you start > Back up configurations, keep an administrative session open and ensure trusted recovery access (e.g. a provider console). Migrate one server at a time, including its users, clients and automation. Preserve existing MFA. An existing SSH session authenticated by a potentially forgeable key is not necessarily trustworthy. ## 1. Prepare clients and identify the server version On every client (including automation accounts), set these options before any conflicting settings or includes: ```sshconfig # ~/.ssh/config (client machine; top of file) Host * UpdateHostKeys no StrictHostKeyChecking yes VerifyHostKeyDNS no ``` Otherwise automatic host-key learning can let a server authenticated by a forgeable ECC key plant its own "new" keys. Verify effective settings for each destination; check script overrides and custom configurations too. Keep these settings for migrated hosts. Unknown host keys are now rejected without prompting. Verify the fingerprint out of band and add the key to `known_hosts` (step 5), or, for hosts outside the migration, use `-o StrictHostKeyChecking=ask` once and accept only an independently verified fingerprint. ```bash ssh -G server | grep -Ei '^(updatehostkeys|stricthostkeychecking|verifyhostkeydns) ' ``` On the server, check the installed server package (use the appropriate package manager): ```bash # Debian / Ubuntu dpkg-query -W openssh-server # RPM-based distributions rpm -q openssh-server # Arch Linux pacman -Q openssh # Alpine Linux apk info -v openssh-server ``` Alternatively, from the client machine, check the running daemon's banner (authentication may fail; do not accept unverified keys): ```bash ssh -v -o ControlPath=none -o BatchMode=yes -o ConnectTimeout=10 \ -o PreferredAuthentications=none user@server true 2>&1 | grep -i 'remote software version' ``` On the server, inspect its effective configuration: ```bash sudo sshd -T | grep -Ei '^(kexalgorithms|hostkeyalgorithms|pubkeyaccepted(algorithms|keytypes)|hostkey|authenticationmethods) ' ``` On the client machine, check available algorithms: ```bash ssh -V ssh -Q kex | grep -E 'mlkem|sntrup' ssh -Q key | grep mldsa ssh -Q sig | grep mldsa ``` > [!note] > Backports, FIPS mode and crypto policies can change availability. Trust `sshd -T` and a fresh connection, not version numbers alone. `ssh -Q` lists local client capabilities. ## 2. Choose a migration path For any server below 10.6p2, check supported repositories and official backports first. If an upgrade is available, install it, restart/reload as required, and return to step 1. > [!warning] Upgrading from 10.4/10.5 > Search client and server configs (including custom includes) for experimental `mldsa` settings: `grep -rin mldsa /etc/ssh ~/.ssh/config ~/.ssh/config.d 2>/dev/null`. Remove obsolete algorithm restrictions **before** upgrading; ensure tested alternative access or a console. After upgrading, run `sshd -t`, verify the service and regenerate experimental keys: the final format drops the vendor suffix and is incompatible. Renaming is insufficient. | OpenSSH | PQ KEX | PQ auth | If no upgrade is available | | --- | :---: | :---: | --- | | < 8.5 | ❌ | ❌ | Isolate / replace (step 3) | | 8.5–9.8 | ✅ | ❌ | NTRU + interim RSA | | 9.9–10.3 | ✅ | ❌ | ML-KEM + interim RSA | | 10.4–10.5 | ✅ | ⚠️ | ML-KEM + interim RSA | | ≥ 10.6 | ✅ | ✅ | Full migration (prefer ≥ 10.6p2) | NTRU is disabled by default on 8.5–8.8 clients and servers. Clients older than 8.5 cannot negotiate the modern NTRU method used here. ⚠️ denotes experimental hybrid signatures, not the final format. ## 3. Enforce post-quantum key exchange > [!note] Configuration files > `00-pqc.conf` below means `/etc/ssh/sshd_config.d/00-pqc.conf` if included in the global section. Otherwise use `/etc/ssh/sshd_config` before any `Match` block (`Include` is supported upstream since 8.2). For most options the first applicable value wins; resolve conflicting directives and check `sshd -T`. > [!warning] > Test every required client and automation job before enforcing. On 10.6+ servers, `WarnWeakCrypto` (enabled by default) logs clients using non-PQ KEX. Check SSH service logs for legacy clients. ### OpenSSH < 8.5 Upgrade or replace. If impossible, restrict access to a separate trusted management network/tunnel (which itself may not be PQ-safe). This is containment, not a PQC upgrade. ### OpenSSH 8.5–9.8 ```sshconfig # 00-pqc.conf KexAlgorithms sntrup761x25519-sha512@openssh.com ``` On 8.5–8.8 clients, explicitly enable the same KEX before changing the server: ```sshconfig # ~/.ssh/config (client machine; before conflicting KEX settings) Host server.example.org KexAlgorithms sntrup761x25519-sha512@openssh.com ``` ### OpenSSH ≥ 9.9 ```sshconfig # 00-pqc.conf KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,sntrup761x25519-sha512@openssh.com ``` > [!info] Algorithm names > `@openssh.com` is a literal vendor namespace, not a hostname. Both NTRU names denote the same KEX; the unsuffixed name appeared in 9.9. These allowlists exclude classical-only KEX fallback. If every client supports ML-KEM, prefer `KexAlgorithms mlkem768x25519-sha256` on both sides. Otherwise retain NTRU for compatibility. Use only algorithms supported by the installed build. Validate, reload and test (step 5) before continuing. Use independently authenticated access if old host signatures may be forgeable. ## 4. Migrate authentication Use a current client (preferably ≥ 10.6p2). Choose one path below. > [!danger] Minimize the staging window > If ECC signatures are forgeable, an authorized standalone ECC key can enable impersonation using only its public key. Restrict ingress where feasible. Provision keys and verify fingerprints via a trusted console or independently authenticated connection; use `ssh-copy-id` only over such a connection. Enforce, retest and remove superseded keys on this server before moving to the next. Suspected intrusion → investigate and recover/rebuild first. > [!warning] Hardware-backed keys (both paths) > FIDO SSH keys (`sk-ssh-ed25519@openssh.com`, `sk-ecdsa-sha2-nistp256@openssh.com`) use potentially affected curves. Hardware isolation does not fix a mathematical break. OpenSSH 10.6 has no FIDO hybrid key type; switching to software RSA or hybrid keys loses hardware protection. Preserve required MFA or equivalent safeguards. ### A. OpenSSH 8.0–10.5 — interim RSA authentication RSA is a temporary alternative to potentially weakened ECC, **not PQ authentication**. Upgrade wherever possible. On the client machine (generate once per intended client identity): ```bash ssh-keygen -t rsa -b 4096 -a 256 -f ~/.ssh/id_rsa_transition ssh-copy-id -o ControlPath=none -i ~/.ssh/id_rsa_transition.pub user@server ``` On the server, inspect host-key paths and the configured RSA key (adjust paths as needed): ```bash sudo sshd -T | grep '^hostkey ' sudo ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub ``` Keep an existing RSA host key ≥ 3072 bits if trusted; otherwise generate a new key without overwriting the old one: ```bash sudo ssh-keygen -t rsa -b 4096 -N '' -f /etc/ssh/ssh_host_rsa_transition_key sudo ssh-keygen -lf /etc/ssh/ssh_host_rsa_transition_key.pub ``` Put the replacement RSA key first and remove the old RSA entry from the active list. Preserve other host-key types during staging. A single explicit `HostKey` suppresses implicit defaults; with two RSA keys the first may be selected. Adapt this example to the actual paths and resolve other active `HostKey` directives: ```sshconfig # 00-pqc.conf HostKey /etc/ssh/ssh_host_rsa_transition_key HostKey /etc/ssh/ssh_host_ecdsa_key HostKey /etc/ssh/ssh_host_ed25519_key ``` Check `sudo sshd -T | grep '^hostkey '`, independently verify and pin the intended RSA key on clients (step 5), then reload and test: ```bash ssh -vvv -o ControlPath=none \ -o HostKeyAlgorithms=rsa-sha2-512,rsa-sha2-256 \ -o PubkeyAcceptedAlgorithms=rsa-sha2-512,rsa-sha2-256 \ -o IdentitiesOnly=yes -i ~/.ssh/id_rsa_transition user@server true ``` Complete required MFA; confirm successful login, the pinned host fingerprint and `sign_and_send_pubkey: signing using rsa-sha2-512` (or `rsa-sha2-256`) with the intended user key. Immediately after required clients/accounts pass, enforce on the server (≥ 8.5), reload and retest: ```sshconfig # 00-pqc.conf HostKeyAlgorithms rsa-sha2-512,rsa-sha2-256 PubkeyAcceptedAlgorithms rsa-sha2-512,rsa-sha2-256 ``` For 8.0–8.4 only (no modern PQ KEX), use the old directive name. Earlier versions handle this allowlist incorrectly; isolate/replace instead. ```sshconfig # 00-pqc.conf HostKeyAlgorithms rsa-sha2-512,rsa-sha2-256 PubkeyAcceptedKeyTypes rsa-sha2-512,rsa-sha2-256 ``` Do not enable SHA-1 `ssh-rsa` signatures (RSA public-key files may still begin with `ssh-rsa`). Audit RSA user-key sizes too: ≥ 3072 bits, 4096 for new keys. On ≥ 9.1, enforce the minimum after migrating required keys: ```sshconfig # 00-pqc.conf RequiredRSASize 3072 ``` ### B. OpenSSH ≥ 10.6 — hybrid authentication On the client machine (skip generation if you already have a final-format key): ```bash ssh-keygen -t mldsa44-ed25519 -a 256 ssh-copy-id -o ControlPath=none -i ~/.ssh/id_mldsa44_ed25519.pub user@server ``` `-a 256` is a tunable private-key password KDF cost, not a signature parameter. Use a strong passphrase. On the server, generate missing host keys and obtain the fingerprint: ```bash sudo ssh-keygen -A sudo ssh-keygen -lf /etc/ssh/ssh_host_mldsa44_ed25519_key.pub ``` If `HostKey` entries are already explicit and the hybrid key is missing, add it while preserving existing entries (otherwise the implicit defaults already include it): ```sshconfig # 00-pqc.conf HostKey /etc/ssh/ssh_host_mldsa44_ed25519_key ``` Independently verify and pin the new host key (step 5), reload, then test. Classical host keys can still be preferred by default; force the intended algorithms: ```bash ssh -vvv -o ControlPath=none \ -o KexAlgorithms=mlkem768x25519-sha256 \ -o HostKeyAlgorithms=ssh-mldsa44-ed25519 \ -o PubkeyAcceptedAlgorithms=ssh-mldsa44-ed25519 \ -o IdentitiesOnly=yes -i ~/.ssh/id_mldsa44_ed25519 user@server true ``` Complete required MFA; confirm successful login, the pinned host fingerprint and `sign_and_send_pubkey: signing using ssh-mldsa44-ed25519` with the intended user key. Immediately after required clients/accounts pass, enforce on the server, reload and retest: ```sshconfig # 00-pqc.conf HostKeyAlgorithms ssh-mldsa44-ed25519 PubkeyAcceptedAlgorithms ssh-mldsa44-ed25519 ``` > [!tip] Why keep Ed25519 in a hybrid key? > Both ML-DSA-44 and Ed25519 signatures must verify. Breaking Ed25519 alone does not enable hybrid forgery; allowing standalone Ed25519 as an alternative would undermine the migration. ## 5. Validate, reload and verify After each configuration change, on the server (use the actual service name/manager): ```bash sudo sshd -t && sudo systemctl reload sshd # ssh on Debian/Ubuntu ``` Keep the existing administrative session open. From the client machine, test a fresh connection: ```bash ssh -vvv -o ControlPath=none user@server true 2>&1 | grep -Ei 'kex: algorithm|kex: host key algorithm|Server host key|Server accepts key|sign_and_send_pubkey: signing|Authenticated to' ``` Check successful authentication and actual key fingerprints. `Server accepts key` alone is insufficient. The filtered output is diagnostic; check the SSH exit status separately when scripting. | Component | Interim | Full migration | | --- | --- | --- | | KEX | ML-KEM or NTRU | `mlkem768x25519-sha256` preferred | | Host signature | `rsa-sha2-512` / `rsa-sha2-256` | `ssh-mldsa44-ed25519` | | User signature | RSA/SHA-2 | `ssh-mldsa44-ed25519` | Optional: enumerate the remote server's advertised algorithms (not proof of successful authentication): ```bash nmap -p 22 --script ssh2-enum-algos server ``` ### Host trust: verify and pin before testing authentication > [!danger] > Server-side restrictions cannot stop an impersonator offering an old ECC host key. Clients must reject it. Remove old and unverified entries (including automatically learned hybrid keys), then pin only independently verified keys. Obtain the new host public key and its fingerprint through a trusted console or independently authenticated inventory. Verify it with `ssh-keygen -lf /path/to/verified-host-key.pub`; `ssh-keyscan` alone does not establish trust. Inspect all destination aliases/IPs and trust sources on each client: ```bash ssh -G server.example.org | grep -Ei '^(hostname|port|hostkeyalias|(user|global)knownhostsfile|knownhostscommand|verifyhostkeydns|checkhostip) ' ``` Back up trust files securely. Remove old entries for every applicable identity (example for the default user trust file; replace names/IPs/ports): ```bash # Client machine cp -p ~/.ssh/known_hosts ~/.ssh/known_hosts.pre-pqc ssh-keygen -R server.example.org -f ~/.ssh/known_hosts ssh-keygen -R 192.0.2.10 -f ~/.ssh/known_hosts ssh-keygen -R '[server.example.org]:2222' -f ~/.ssh/known_hosts ssh-keygen -R '[192.0.2.10]:2222' -f ~/.ssh/known_hosts ``` Pin the verified public key for each lookup identity (`[host]:port` for non-default ports, unless `HostKeyAlias` overrides the lookup name): ```bash # Client machine; verified-host-key.pub from an independent trusted channel awk 'NR == 1 {print "server.example.org", $1, $2}' \ /path/to/verified-host-key.pub >> ~/.ssh/known_hosts ssh-keygen -F server.example.org -f ~/.ssh/known_hosts ``` Compare fingerprints to the independently verified one. Repeat for aliases/IPs and all active trust sources, including global files and `KnownHostsCommand`. Coordinate managed/shared entries; preserve unrelated trust and revocation records. Do not leave backups active or restore stale ECC trust as a routine rollback. Use trusted recovery access. ## 6. Remove fallback paths - [ ] Retest all required accounts and automation after enforcing allowlists. - [ ] Remove superseded user keys from `authorized_keys` and other authorization sources. - [ ] Review alternative authentication (passwords, GSSAPI, host-based auth, CAs, `Match` overrides). For ordinary key-only authentication, apply the four authentication settings in step 7 (also for interim servers); preserve required MFA instead if applicable. - [ ] On every client, complete host trust cleanup (step 5) and enforce the per-host policy below for all aliases and automation paths. Verify with `ssh -G`. - [ ] Close the original session only after verifying new connections and recovery access. For a fully migrated server: ```sshconfig # ~/.ssh/config (client machine; before conflicting algorithm settings) Host server.example.org KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,sntrup761x25519-sha512@openssh.com HostKeyAlgorithms ssh-mldsa44-ed25519 PubkeyAcceptedAlgorithms ssh-mldsa44-ed25519 IdentityFile ~/.ssh/id_mldsa44_ed25519 IdentitiesOnly yes ``` For an ML-KEM-capable interim server (modern client): ```sshconfig # ~/.ssh/config (client machine; before conflicting algorithm settings) Host interim.example.org KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,sntrup761x25519-sha512@openssh.com HostKeyAlgorithms rsa-sha2-512,rsa-sha2-256 PubkeyAcceptedAlgorithms rsa-sha2-512,rsa-sha2-256 RequiredRSASize 3072 IdentityFile ~/.ssh/id_rsa_transition IdentitiesOnly yes ``` For NTRU-only servers use the suffixed NTRU name. On clients 8.5–9.0 omit `RequiredRSASize` and verify sizes manually; on 8.5–9.8 omit unsupported KEX names. Do not enforce hybrid-only algorithms globally while legacy hosts remain. ## 7. Final server configuration (full migration) For ≥ 10.6, hybrid host key installed, all clients migrated, ordinary public-key authentication only (no PAM MFA or certificates). Remove conflicting directives and other active `HostKey` entries if loading only the hybrid key is intended. The last four settings enforce key-only authentication. ```sshconfig # 00-pqc.conf KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,sntrup761x25519-sha512@openssh.com HostKey /etc/ssh/ssh_host_mldsa44_ed25519_key HostKeyAlgorithms ssh-mldsa44-ed25519 PubkeyAcceptedAlgorithms ssh-mldsa44-ed25519 PubkeyAuthentication yes PasswordAuthentication no KbdInteractiveAuthentication no AuthenticationMethods publickey ``` > [!note] Scope > SSH certificates and CA trust require separate migration. This is not CNSA 2.0 compliance (which requires ML-KEM-1024 and ML-DSA-87). Check service startup arguments and distribution policies; use `sshd -T -C user=USER,host=CLIENT_HOST,addr=CLIENT_IP` for applicable `Match` rules. Not integration-tested across all releases — validate per server. ## References - [OpenSSH: Post-Quantum Cryptography](https://www.openssh.org/pq.html) - [OpenSSH release notes](https://www.openssh.org/releasenotes.html) (8.0: RSA/SHA-2-only fix, bz#2746; 10.6: final hybrid format) - [sshd_config(5)](https://man.openbsd.org/sshd_config) · [ssh_config(5)](https://man.openbsd.org/ssh_config) · [ssh-keygen(1)](https://man.openbsd.org/ssh-keygen) - [NSA advisory](https://www.nsa.gov/Press-Room/Press-Releases-Statements/Press-Release-View/Article/4662430/nsa-advises-immediate-transition-to-post-quantum-cryptography-to-protect-nation/) · [Joint government statement](https://www.nsa.gov/Press-Room/Press-Releases-Statements/Press-Release-View/Article/4662453/joint-statement-from-oncd-nsa-and-cisa-on-recent-advances-in-cryptographic-and/) - [Filippo Valsorda — What to Make of the NSA Advisory](https://words.filippo.io/nsa-advisory/) - [Joint industry statement on PQC](https://www.anthropic.com/news/joint-statement-post-quantum-cryptography) #security #cryptography #PQC #SSH #OpenSSH #Linux #sysadmin