Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Post-quantum key exchange in SSH

After this lesson: I can read which key exchange an SSH connection used and say whether it is post-quantum.

60 min lesson10 commandsPost-quantum cryptography lab: ML-KEM, ML-DSA, hybrid TLS and post-quantum SSH with OpenSSL 3.5 and OpenSSH 10

What post-quantum SSH is

Post-quantum SSH means the key exchange that starts every SSH session uses ML-KEM as well as a classical method. OpenSSH 10 does this by default, so most people already use it without knowing.

Admins copy files, run backups and manage servers over SSH every day. A recording of those sessions is worth breaking later, so SSH moved early.

By the end of this lesson

Note

I can read which key exchange an SSH connection used and say whether it is post-quantum.

Key words

WordWhat it means
SSHsecure shell, for logging in to and controlling another computer
KEXshort for key exchange, the first step of an SSH session
mlkem768x25519-sha256OpenSSH's hybrid of ML-KEM-768 and X25519
Host keythe server's signing key, which proves it is the right server
Verbose modessh -v, which prints each step of a connection

The cells students fill in are left blank in this preview.

OpenSSH moved to post-quantum early

OpenSSH 9.0, in 2022, made sntrup761x25519-sha512 its default, a hybrid using a lattice KEM called Streamlined NTRU Prime. OpenSSH 9.9 added mlkem768x25519-sha256, and OpenSSH 10.0 made it the default.

Both are hybrids with X25519, so both count as post-quantum. The host key is still Ed25519, a classical signature. That is checked live, so a recording cannot be used to break it later.

Worked example: SSH key exchanges

NameWhat it isPost-quantum?
mlkem768x25519-sha256ML-KEM-768 with X25519, the default in OpenSSH 10Yes, hybrid
sntrup761x25519-sha512NTRU Prime with X25519, the default in 9.0 to 9.9Yes, hybrid
curve25519-sha256X25519 aloneNo
ecdh-sha2-nistp256Elliptic curve P-256 aloneNo

The cells students fill in are left blank in this preview.

How SSH agrees a key exchange

Each side sends its list of key exchanges. SSH picks the first one in the client's list that the server also has. If they share none, the connection stops before any login.

In the lab, ssh sshd reaches the default server on port 2222. ssh legacy reaches the same server set up like an old one on port 2200, offering only classical methods.

Which OpenSSH is the client

Command
docker exec pq ssh -V

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

List the post-quantum key exchanges

Command
docker exec pq sh -c "ssh -Q kex | grep -E 'mlkem|sntrup'"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

The client's list, in order

Command
docker exec pq sh -c "ssh -G sshd | grep ^kexalgorithms"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Log in and run one command

Command
docker exec pq ssh sshd whoami

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Which key exchange was agreed

Command
docker exec pq sh -c "ssh -v sshd true 2>&1 | grep 'kex: algorithm'"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Which OpenSSH is the server

Command
docker exec pq sh -c "ssh -v sshd true 2>&1 | grep 'remote software version'"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

What the Runs print

RunWhat it prints
ssh -VOpenSSH_10.0p2 Debian-7+deb13u4, OpenSSL 3.5.7 9 Jun 2026
ssh -Q kex, filteredsntrup761x25519-sha512, [email protected], mlkem768x25519-sha256
ssh -G, filteredkexalgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,... then the classical ones
ssh sshd whoamiabc, the account on the server
kex: algorithmdebug1: kex: algorithm: mlkem768x25519-sha256
remote software versiondebug1: Remote protocol version 2.0, remote software version OpenSSH_10.3

The cells students fill in are left blank in this preview.

Force a classical key exchange

Command
docker exec pq sh -c "ssh -v -o KexAlgorithms=curve25519-sha256 sshd true 2>&1 | grep 'kex: algorithm'"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Connect to the old-style server

Command
docker exec pq sh -c "ssh -v legacy true 2>&1 | grep 'kex: algorithm'"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Ask the old server for ML-KEM only

Command
docker exec pq sh -c "ssh -o LogLevel=INFO -o KexAlgorithms=mlkem768x25519-sha256 legacy true 2>&1 | cut -d: -f2-"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

The old server's own list

Command
docker exec sshd sh -c "/usr/sbin/sshd.pam -T -f /tmp/sshd/legacy_config | grep ^kexalgorithms"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

What the classical Runs print

RunWhat it prints
Forced curve25519debug1: kex: algorithm: curve25519-sha256
ssh legacydebug1: kex: algorithm: curve25519-sha256
ML-KEM only to legacyno matching key exchange method found. Their offer: curve25519-sha256,ecdh-sha2-nistp256,ext-info-s,[email protected]
sshd -T on the old serverkexalgorithms curve25519-sha256,ecdh-sha2-nistp256

The cells students fill in are left blank in this preview.

A common mistake

Warning

Many people think a new SSH client protects every connection. The server has a say: an old server agrees classical X25519, and the login works with no question asked. Read the kex line, or fix the server, before you trust a session.

About this lab and its source: Post-quantum cryptography lab: ML-KEM, ML-DSA, hybrid TLS and post-quantum SSH with OpenSSL 3.5 and OpenSSH 10

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.