Your Mac's SSH skips post-quantum key exchange: the one-line fix
By Flavio
Tagged: CLI
macOS ships an OpenSSH config that forces plain elliptic-curve key exchange first. One line in ~/.ssh/config turns post-quantum key exchange back on.
Even on a modern Mac running OpenSSH 10, ssh still uses a classical elliptic-curve key exchange by default, even when the server on the other end already supports post-quantum encryption.
Before we look at the one-line fix in ~/.ssh/config, let’s start from the basics: what is post-quantum key exchange, what problem does it solve, and why are people turning it on today?
What post-quantum key exchange is (and why it matters now)
Every time you open an SSH connection, your computer and the server need to agree on a shared secret key before they send anything private.
That first step is called key exchange. Once both sides agree on that temporary session key, they use it to encrypt the rest of the session.
For years, SSH has done this with classical math like RSA or elliptic curves (ecdh-sha2-nistp256 and curve25519-sha256). Ordinary computers cannot reverse that math fast enough to recover your session key, so your traffic stays private.
Quantum computers change that assumption. A large enough quantum computer can run algorithms that break classical elliptic-curve and RSA key exchange.
You might wonder why we care about this today if practical quantum computers are still years away.
The problem is called “harvest now, decrypt later”. Anyone sitting on a network path (an ISP, a compromised router, a state actor) can record your encrypted SSH sessions today and save the raw packets on disk. Years from now, when quantum hardware catches up, they can go back to those saved handshakes, break the classical key exchange, recover the session keys, and read traffic you thought was private.
So key exchange is the first piece of SSH to move, ahead of your SSH login keys or host keys. A future quantum computer cannot go back in time to fake a login you already finished, but it can decrypt recorded sessions if the handshake wasn’t quantum-safe.
Post-quantum cryptography replaces that vulnerable handshake with math problems that quantum computers are not known to break, such as lattice-based algorithms like ML-KEM (standardized by NIST) and Streamlined NTRU Prime.
Because those algorithms are newer than elliptic curves, OpenSSH uses hybrid key exchanges like mlkem768x25519-sha256 and sntrup761x25519-sha512. Each one combines a post-quantum algorithm with classical X25519 in the same handshake. If either side ever turns out to have a weakness in the future, the other side still protects the session key.
Check what your Mac is using right now
OpenSSH has supported post-quantum key exchange for years, and major Git hosts and modern Linux servers already ship it.
The problem on macOS is that Apple ships a system config file at /etc/ssh/crypto.conf that forces ecdh-sha2-nistp256 to the front of the list.
So your Mac will silently skip post-quantum key exchange unless you override it.
You can check what your Mac negotiates right now against any server you connect to:
ssh -v yourserver true 2>&1 | grep "kex: algorithm"
If you don’t want to touch a VPS right now, you can test against GitHub without even authenticating, because key exchange happens before login:
ssh -v -T git@github.com 2>&1 | grep "kex: algorithm"
Look at the algorithm name it prints:
ecdh-sha2-nistp256means plain elliptic-curve key exchange, not post-quantum.mlkem768x25519-sha256orsntrup761x25519-sha512(orsntrup761x25519-sha512@openssh.com) means a post-quantum hybrid key exchange.
Why macOS skips it by default
Let’s see what macOS actually ships. On my Mac, ssh -V reports OpenSSH_10.5p1, which supports post-quantum key exchange out of the box.
The catch is in /etc/ssh/ssh_config.d/100-macos.conf, which is included by macOS from /etc/ssh/ssh_config. It loads /etc/ssh/crypto.conf, which is a symlink to /etc/ssh/crypto/apple.conf (you can also read the source in Apple’s OpenSSH repository).
Here’s what those files contain on my machine:
ssh -V
cat /etc/ssh/crypto.conf
cat /etc/ssh/ssh_config.d/100-macos.conf
And the output:
OpenSSH_10.5p1, LibreSSL 3.3.6
# Default algorithms favoring higher-performance FIPS algorithms
# in most cases.
#
# To configure these SSH algorithms, run the following command:
#
# sudo ln -fs crypto/apple.conf /etc/ssh/crypto.conf
#
Ciphers ^aes128-gcm@openssh.com,aes256-gcm@openssh.com
KexAlgorithms ^ecdh-sha2-nistp256
MACs ^hmac-sha2-256-etm@openssh.com,hmac-sha2-256
Host *
SendEnv LANG LC_*
Include /etc/ssh/crypto.conf

Notice the caret (^) in KexAlgorithms ^ecdh-sha2-nistp256.
In OpenSSH config syntax, ^ prepends an algorithm to the front of the default list, instead of replacing the list.
So macOS moves ecdh-sha2-nistp256 ahead of mlkem768x25519-sha256 and sntrup761x25519-sha512.
During the handshake, the client and server compare their lists and pick the first algorithm in the client’s list that the server also supports.
Almost every SSH server supports ecdh-sha2-nistp256, so your Mac picks it right away, and never even reaches the post-quantum options that are right behind it.
The one-line fix in ~/.ssh/config
We don’t want to edit files under /etc/ssh/ because a macOS update can overwrite them.
Instead we can take advantage of how OpenSSH reads config files. As I cover in SSH for developers, ssh reads your personal ~/.ssh/config before /etc/ssh/ssh_config, and for most options the first value it sees wins.
Put this line at the very top of ~/.ssh/config, above any Host block, so it applies before anything else:
KexAlgorithms ^mlkem768x25519-sha256,sntrup761x25519-sha512
This is the prepend version, from the Sudolabs write-up.
Because of the ^, OpenSSH puts mlkem768x25519-sha256 and sntrup761x25519-sha512 at the top of its built-in default list, and ignores /etc/ssh/crypto.conf. All the other default algorithms (sntrup761x25519-sha512@openssh.com, curve25519-sha256, ecdh-sha2-nistp256 and the rest) will be put behind them as fallbacks.
You can also write it without the ^ if you want a strict list:
KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512@openssh.com,curve25519-sha256
There is an important difference between the two. With ^, you only change the priority order. If you connect to an older server or router that only speaks ecdh-sha2-nistp256 or diffie-hellman-group14-sha256, SSH falls back and connects.
Without ^, you replace the entire list. Only those 3 algorithms are allowed, and an old server that does not support any of them will fail with a no matching key exchange method found error instead of silently falling back to an older curve.
Notice also that the strict list uses sntrup761x25519-sha512@openssh.com with the @openssh.com suffix, because servers running OpenSSH 9.0 to 9.8 only know that name (OpenSSH 9.9 added the shorter name without the suffix).
On my Mac I use the ^ prepend form. Modern servers will jump straight to mlkem768x25519-sha256, and I don’t get locked out of older boxes when I need to log into one.
Before and after on my Mac
Let’s check the real output on my machine. Passing -F /etc/ssh/ssh_config tells ssh to use only macOS’s default system config, so we can compare before and after in the same terminal.
First, testing Git over SSH against github.com:
ssh -v -F /etc/ssh/ssh_config -T git@github.com 2>&1 | grep "kex: algorithm"
debug1: kex: algorithm: ecdh-sha2-nistp256
Now with the fix in ~/.ssh/config:
ssh -v -T git@github.com 2>&1 | grep "kex: algorithm"
debug1: kex: algorithm: mlkem768x25519-sha256
You can also inspect the resolved algorithm list without opening a connection using ssh -G:
ssh -G -F /etc/ssh/ssh_config github.com | grep '^kexalgorithms'
ssh -G github.com | grep '^kexalgorithms'
With the default macOS config, ecdh-sha2-nistp256 is at index zero.
After the fix, mlkem768x25519-sha256 moves to the front and ecdh-sha2-nistp256 drops back into the fallback tail:

I ran the same check from my Mac against 4 Git hosts I use or test with, and every single one behaved this way:
| Host | Remote software | macOS default | After ~/.ssh/config fix |
|---|---|---|---|
github.com | 91c8027f | ecdh-sha2-nistp256 | mlkem768x25519-sha256 |
gitlab.com | GitLab-SSHD | ecdh-sha2-nistp256 | mlkem768x25519-sha256 |
codeberg.org | OpenSSH_10.0p2 Debian-7+deb13u4 | ecdh-sha2-nistp256 | mlkem768x25519-sha256 |
bitbucket.org | conker_761dff656e | ecdh-sha2-nistp256 | mlkem768x25519-sha256 |
Run the check on your own VPS and production servers too:
ssh -v yourserver true 2>&1 | grep "kex: algorithm"
If an older server does not support post-quantum key exchange yet, your Mac will fall back to classical key exchange even after this fix, so check the hosts you actually log into.
What your server needs
Key exchange takes two sides, so both your Mac and the server must have an OpenSSH version that supports post-quantum algorithms.
First, check your Mac client version with ssh -V. Mine prints OpenSSH_10.5p1, LibreSSL 3.3.6.
On the server side, here is what each OpenSSH release supports:
| Server OpenSSH version | Common Linux distros | Post-quantum support | Negotiated algorithm |
|---|---|---|---|
| 8.9 or older | Ubuntu 22.04 LTS (8.9p1) | None | Classical fallback (curve25519-sha256 or ecdh-sha2-nistp256) |
| 9.0 to 9.8 | Debian 12 (9.2p1), Ubuntu 24.04 LTS (9.6p1) | Streamlined NTRU Prime + X25519 | sntrup761x25519-sha512@openssh.com |
| 9.9 | Backports and rolling distros | Adds ML-KEM-768 + X25519 and un-suffixed NTRU name | mlkem768x25519-sha256 or sntrup761x25519-sha512 |
| 10.0 or newer | Debian 13 (10.0p1) | ML-KEM-768 + X25519 becomes upstream default | mlkem768x25519-sha256 |
If your VPS is still on Ubuntu 22.04 (OpenSSH 8.9p1), fixing ~/.ssh/config on your Mac will make your Git hosts and newer servers use post-quantum, but that older server will continue to use classical key exchange until you upgrade the OS.
If you manage your own VPS servers and want a complete refresher on keeping them up to date and locked down, grab the free Linux Server Handbook.
Want me to talk about your product? You can sponsor this site.
Related posts about cli: