SSH against quantum computers
Our mesh speaks post-quantum now: hybrid ML-KEM for the exchange, ML-DSA for sign-in — and how to build OpenSSH for it on Ubuntu and Gentoo.
SSH is how you reach every server. In our mesh it has been running post-quantum safe for a few days: the traffic is encrypted so that even a future quantum computer cannot open recorded sessions afterwards.
Our mesh now speaks post-quantum: hybrid ML-KEM for the exchange, ML-DSA for sign-in — and an OpenSSH that you build yourself for it on Ubuntu and Gentoo.
A quantum computer solves certain tasks faster than any machine today, among them breaking the methods almost everything relies on. Post-quantum means: the method holds even when that computer exists. It does not mean the computer is already here, and not that nobody is listening. It only means that recorded traffic cannot be opened later with it.
Two things have to be kept apart here, and they are easily confused: the session and the identity. For the session there have been hybrid methods for years, for the identity only recently.
Two halves of a connection
Anyone who understands SSH knows the sequence in two steps:
- Key exchange — client and server agree on a session key. Everything that flows afterwards is encrypted with it.
- Authentication — the client proves with its signature that it is who it claims to be; the server proves the same with its host key.
Both steps usually rest on elliptic curves today: X25519 for the exchange, Ed25519 for signatures. A sufficiently large quantum computer breaks both with Shor’s algorithm — the exchange and the signature.
The difference is timing. A session recorded today can be decrypted later, once the machine exists (“harvest now, decrypt later”). A signature can be forged later — then it looks as if the right server answered while someone else does.
The exchange has been hybrid for years
OpenSSH has done this correctly for years: the default is not a single method but a combination of a classical and a post-quantum method. In our mesh the negotiated algorithm is:
sntrup761x25519-sha512@openssh.com
A curve part (X25519) and a lattice part (NTRU Prime) — the session key emerges from both. Whoever records the traffic must break both methods — as long as neither of them has fallen. Anyone collecting today does not get far with a quantum computer alone, because the classical part still holds.
Since OpenSSH 10.0 a different algorithm is the default:
mlkem768x25519-sha256
ML-KEM-768 is the standardised lattice algorithm (FIPS 203), here hybrid with X25519. Which methods a version supports, it shows itself:
ssh -Q kex | grep -E "mlkem|sntrup"
The signature was the open rest
For sign-in and the host key, Ed25519 remained — and with it a method that a quantum computer can break later. A connection built now is safe. But whoever records it and opens it in twenty years can decrypt the session and rebuild the signature.
Since OpenSSH 10.4 there is a hybrid signature key, at first as an experiment with
an @openssh.com suffix in the name. Since 10.6 it is switched on by default and
is called:
ssh-mldsa44-ed25519
ML-DSA-44 (NIST security level 2)
combined with Ed25519. Here too both methods must fall, not just one. Keys from the
10.4 experiment carry the @openssh.com suffix and cannot be reused; they have to
be generated again. Such a key is created, checked and entered into
authorized_keys like any other:
ssh-keygen -t mldsa44-ed25519 -f ~/.ssh/id_pq -C "gustl@mesh"
The output names the method:
Your identification has been saved in /home/gustl/.ssh/id_pq
Your public key has been saved in /home/gustl/.ssh/id_pq.pub
The key fingerprint is:
SHA256:... gustl@mesh (MLDSA44-ED25519)
Why build it yourself
Ubuntu 24.04 ships OpenSSH 9.6. It knows NTRU Prime for the exchange, but neither ML-KEM nor an ML-DSA key. Gentoo is usually faster, but there too you have to choose the version.
The route we took: a second OpenSSH installation next to the system one, in its own prefix, on its own port. The system SSH on port 22 stays untouched — it is the way back if the new service misbehaves. That keeps the old access as a fallback.
curl -LO https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.6p2.tar.gz
Before unpacking, compare the checksum with the one published at
openssh.com:
sha256sum openssh-10.6p2.tar.gz.
Ubuntu: build and run as a service
Missing headers are the most common reason the first build fails:
sudo apt install build-essential zlib1g-dev libssl-dev libpam0g-dev
tar xf openssh-10.6p2.tar.gz && cd openssh-10.6p2
./configure --prefix=/opt/openssh-pq --with-pam
make -j"$(nproc)"
sudo make install
The configuration then lives in /opt/openssh-pq/etc/sshd_config. Two lines in it
are the core:
Port 2222
ListenAddress 192.0.2.42
ListenAddress binds the service to the mesh address; from outside it is not
reachable at all, even if the firewall ever sleeps.
The service as a systemd unit:
# /etc/systemd/system/sshd-pq.service
[Unit]
Description=OpenSSH 10.6 (post-quantum), port 2222
After=network.target
[Service]
ExecStart=/opt/openssh-pq/sbin/sshd -D -f /opt/openssh-pq/etc/sshd_config
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo /opt/openssh-pq/sbin/sshd -t -f /opt/openssh-pq/etc/sshd_config
sudo systemctl daemon-reload
sudo systemctl enable --now sshd-pq
If a firewall is running, you need a rule as well — but only if the service is not bound to the mesh address anyway.
Gentoo: same build, different service
The tools are usually present on a Gentoo system; only the headers the build needs are missing:
sudo emerge --ask dev-libs/openssl sys-libs/pam
Then the same configure call as above. It is started via OpenRC:
#!/sbin/openrc-run
# /etc/init.d/sshd-pq
command="/opt/openssh-pq/sbin/sshd"
command_args="-f /opt/openssh-pq/etc/sshd_config"
pidfile="/run/sshd-pq.pid"
command_background=true
depend() {
need net
}
sudo chmod +x /etc/init.d/sshd-pq
sudo rc-update add sshd-pq default
sudo rc-service sshd-pq start
For the service to find its PID, the configuration needs
PidFile /run/sshd-pq.pid.
The user without root and its key
A dedicated user who may sign in but does not have to administer anything:
adduser --disabled-password --gecos "" gustl
usermod -aG sudo gustl # Ubuntu
usermod -aG wheel gustl # Gentoo
The public key goes into ~/.ssh/authorized_keys, the permissions stay narrow:
~/.ssh with mode 700, the file with 600. If it is writable for others,
sshd ignores it silently.
The PQ key stands next to the Ed25519 key, not instead of it:
# ~/.ssh/authorized_keys
ssh-mldsa44-ed25519 AAAAC3Nza... gustl@mesh
ssh-ed25519 AAAAC3Nza... gustl@mesh
If a client falls back to the old method, it still gets in — and at the next change you notice who has not come along yet.
The subtlety with the host key
The client decides which host key it wants. If the server offers both — ML-DSA and Ed25519 — an unchanged client picks Ed25519, because it ranks higher in its preference list. The connection is then post-quantum in the exchange, but not in the server identity.
It becomes visible with:
ssh -vv -p 2222 gustl@192.0.2.42 2>&1 | grep -E "kex: algorithm|host key algorithm|Authenticated"
Forced proof works like this:
ssh -o HostKeyAlgorithms=ssh-mldsa44-ed25519 -p 2222 gustl@192.0.2.42
Permanently, via your own ~/.ssh/config:
Host mesh-pq
HostName 192.0.2.42
Port 2222
HostKeyAlgorithms ssh-mldsa44-ed25519
PubkeyAcceptedAlgorithms ssh-mldsa44-ed25519,ssh-ed25519
PubkeyAcceptedAlgorithms
with both methods keeps the way back open. Whoever
enters only the PQ method notices a mistake by one thing: no sign-in works at
all — also a form of security, but an uncomfortable one.
Keep sudo narrow
NOPASSWD: ALL is rarely needed. Better are only the commands that are actually
needed.
sudo visudo -f /etc/sudoers.d/logcheck
Cmnd_Alias LOGS = /usr/bin/journalctl -u sshd-pq --no-pager, \
/usr/bin/journalctl -u ssh --no-pager
Defaults:logcheck !requiretty
logcheck ALL=(root) NOPASSWD: LOGS
- Exact paths and arguments.
sudocompares the string; ajournalctlwithout--no-pageris not covered by the rule — and a pager is a shell you can escape from. !requirettyonly for automation without a terminal.visudo -c -f /etc/sudoers.d/logcheckchecks the file.
Automated connections
Backups and checks need no human at the terminal — and no key that may do
everything. authorized_keys allows conditions per key:
command="/usr/local/bin/logcheck.sh",restrict ssh-mldsa44-ed25519 AAAAC3Nza... backup@monitor
command="…"— whatever the client wants, only this script runs.restrict— switches off port forwarding, agent forwarding, PTY and X11.from="192.0.2.0/24"— optional: only from the mesh.
What may run is decided by the script:
#!/usr/bin/env bash
# /usr/local/bin/logcheck.sh — checks only, changes nothing
set -euo pipefail
journalctl -u sshd-pq --since "1 hour ago" --no-pager -p warning || true
fail2ban: only for port 22
Inside the mesh, fail2ban is barely needed — whoever is not in the network cannot reach port 2222. It is different for the system SSH, which still listens on port 22 and is reachable from everywhere:
sudo apt install fail2ban # Ubuntu
sudo emerge --ask net-analyzer/fail2ban # Gentoo
# /etc/fail2ban/jail.local (Ubuntu) or jail.d/sshd.conf (Gentoo)
[sshd]
enabled = true
maxretry = 3
findtime = 10m
bantime = 1h
On Ubuntu, backend = systemd reads straight from the journal; on Gentoo without
systemd, fail2ban reads /var/log/messages with backend = polling. Check with:
sudo fail2ban-client status sshd
fail2ban is no replacement for keys and no replacement for a narrow AllowUsers
rule. It brakes addresses that overdo it — and hits your own connection if you
mistype. That is why your own address belongs in ignoreip.
Check what you built
ssh -Q kex | grep -E "mlkem|sntrup" # what the client can do
sudo /opt/openssh-pq/sbin/sshd -T | grep -E "port|kexalgorithms|hostkey"
ssh -vv -p 2222 gustl@192.0.2.42 2>&1 | grep -E "kex: |host key"
The second line shows the effective configuration of the new service, not what is written in the file. The third shows what was actually negotiated.
What this does not do
- WireGuard is the next step. For now it stays with X25519; whoever records the handshake can compute the session keys later. We are working on it — the post about it follows here as soon as it stands.
- No FIDO2 hardware.
sk-ssh-ed25519is still an elliptic curve. agedoes not create SSH keys.age-keygen -pqmakes hybrid ML-KEM keys for files; they do not fit intoauthorized_keysand not into sign-in.- No security updates from the distributor. The self-built copy in
/optgets no package updates. Every OpenSSH hole must be pulled in yourself: rebuild,sshd -t, restart the service. That is the price of the new version. So at first it runs next to the system SSH: its own port, its own unit, its own host key. During the test phase the system SSH stays open and is the way back when the new service misbehaves. Whoever has used the new route for weeks without anything missing switches the old access off — then there is only one entrance left, and that one has to be maintained. Before switching it off, the provider console is needed.
The biggest risk currently lies elsewhere: unencrypted keys in ~/.ssh, agent
forwarding, copies on several machines.
Further reading
The topic is bigger than one post. If you want to go deeper:
- RFC 10042 — the
specification behind
mlkem768x25519-sha256: hybrid exchange with ML-KEM for SSH. The binding source when a client or server does not play along. - arXiv — preprints from computer science, physics and mathematics, freely accessible. If you want to see what is being worked on, the drafts are here before the journals.
- Google Scholar — searches arXiv, publisher platforms and conference proceedings together; the fastest route to “is there anything on this yet?”.
- IEEE Xplore and SpringerLink — peer-reviewed articles. Abstracts are free, full texts often cost money.
Windows: Tabby and the system client
Windows ships its own SSH client: ssh in PowerShell or Terminal. Which methods
it supports, ssh -Q kex reveals — if ML-KEM is missing, only a newer version
helps.
Tabby is a terminal for Windows, Linux and macOS, with profiles, shared settings, an SFTP panel and plugins. Find it at tabby.sh.
Tabby cannot do PQ — the detour via the system client
Tabby brings its own SSH client, and it knows neither ML-KEM nor ML-DSA: in the
shipped version 1.0.238 none of the methods is in the program. Instead of waiting
for a new Tabby release, we swap the roles: Tabby becomes the surface, the
cryptography is done by the system ssh. A local profile starts a short
script that sets the PQ options and passes everything on:
#!/usr/bin/env bash
# Signs in with a post-quantum key via the system ssh.
set -euo pipefail
host="${1:?usage: pq-ssh <host> [command ...]}"
shift || true
exec ssh -p 2222 -i "$HOME/.ssh/id_pq" \
-o HostKeyAlgorithms=ssh-mldsa44-ed25519 \
-o PubkeyAcceptedAlgorithms=ssh-mldsa44-ed25519,ssh-ed25519 \
-o IdentitiesOnly=yes \
-- "$host" "$@"
The script is available as a
download — copy it to ~/bin/pq-ssh, make it executable,
done. It checks the key, names the ssh-keygen command if it is missing, and can
be adjusted via PQ_PORT and PQ_KEY. It is released under the MIT licence
(full text, German and English on one page): copy,
change, pass on — as long as the name stays — without warranty.
The stumbling block: a local profile in Tabby expects the field command,
not shell. With shell: no window opens on click and no error appears — then you
look for the fault in the wrong place. This is what the entry looks like:
options:
command: /home/gustl/bin/pq-ssh
args: ["server1"]
cwd: /home/gustl
env: {}
shellType: bash
pauseAfterExit: false
The outer fields — name, type: local, group — Tabby assigns in its
configuration; the field names for local profiles are in the log
(~/.config/tabby/log.txt) when a default profile starts. That is where they come
from.
Register the host key once, otherwise the first call fails at verification:
ssh-keyscan -p 2222 -t ssh-mldsa44-ed25519 server1 >> ~/.ssh/known_hosts
Updates: Tabby lives as a program directory (with us ~/Applications/tabby); an
update replaces program files, not the configuration under
~/.config/tabby/config.yaml. If a new version changes the schema, Tabby converts
the file and writes config.yaml.backup first — the profiles may disappear in the
process. The script lives outside Tabby and is not affected: even if all profiles
are gone, PQ access from the shell keeps working. The profiles are plain data and
can be written again as long as Tabby does not change the field names; a small
script does that idempotently — that is, only what is missing.
For the post-quantum route the client has to play along; otherwise the connection stays classical. Whether it does shows up only in the check.
Sources
All addresses retrieved on 25 November 2026, each answered HTTP 200.
- OpenSSH 10.6 —
ssh-mldsa44-ed25519enabled by default,WarnWeakCrypto: https://www.openssh.com/txt/release-10.6 - OpenSSH 10.4 — hybrid signature
mldsa44-ed25519as an experiment, keys viassh-keygen -t mldsa44-ed25519: https://www.openssh.com/txt/release-10.4 - OpenSSH 10.0 —
mlkem768x25519-sha256as the default key exchange: https://www.openssh.com/txt/release-10.0 - OpenSSH 9.0 —
sntrup761x25519-sha512@openssh.comas the default: https://www.openssh.com/txt/release-9.0 - RFC 10042 — hybrid key exchange with ML-KEM for SSH: https://www.rfc-editor.org/rfc/rfc10042.html
- RFC 7748 — X25519: https://www.rfc-editor.org/rfc/rfc7748
- FIPS 203 — ML-KEM: https://csrc.nist.gov/pubs/fips/203/final
- FIPS 204 — ML-DSA: https://csrc.nist.gov/pubs/fips/204/final
- NTRU Prime: https://ntruprime.cr.yp.to/
- OpenSSH, source and portable distribution: https://www.openssh.com/portable.html
- Ubuntu 24.04,
openssh-client9.6p1: https://packages.ubuntu.com/noble/openssh-client ssh_config(5),PubkeyAcceptedAlgorithms: https://man.openbsd.org/ssh_config#PubkeyAcceptedAlgorithms- fail2ban: https://github.com/fail2ban/fail2ban
- Tabby: https://tabby.sh/
- FIDO2: https://fidoalliance.org/fido2/