To check if your SSH connection is post-quantum, run:
ssh -v -p <port> user@<server> exit 2>&1 | grep 'kex: algorithm'
With Apple’s built-in ssh on macOS, you’ll likely see this:
debug1: kex: algorithm: ecdh-sha2-nistp256
That’s not post-quantum.
You can check if your SSH connection is post-quantum
— View on X
Why it matters
The key exchange (kex) is how your machine and the server agree on the key that encrypts the session. ecdh-sha2-nistp256 uses elliptic curves, which a large enough quantum computer could break. Nobody can do that today, but anyone who records your traffic now can decrypt it later, once they can. That’s called “harvest now, decrypt later”.
A post-quantum kex combines a classic method with a quantum-resistant one, so an attacker would have to break both. OpenSSH supports two:
| Algorithm | Post-quantum part | Since |
|---|---|---|
[email protected] |
Streamlined NTRU Prime | OpenSSH 9.0 (default) |
mlkem768x25519-sha256 |
ML-KEM, the NIST standard | OpenSSH 9.9 (default since 10.0) |
Either one is fine. ML-KEM is the newer, standardized one.
Why a Mac picks the classic one
Two things are going on:
- Apple’s ssh is old. Check it with
ssh -V. Mine isOpenSSH_9.8p1, which supportssntrup761but not ML-KEM. - Apple’s build puts
ecdh-sha2-nistp256first. In SSH, the client’s preference order wins, so as long as the server supports it, that’s what you get.
You can see your client’s order with:
ssh -G <server> | grep -i kexalgorithms
If ecdh-sha2-nistp256 comes first, you’re affected. There are two ways to fix it. Pick one.
Method 1: Apple’s ssh
No install. You only change the preference order.
Add this to the end of ~/.ssh/config (create the file if it doesn’t exist):
Host *
KexAlgorithms [email protected],curve25519-sha256,[email protected],ecdh-sha2-nistp256
Don’t add mlkem768x25519-sha256 here. Apple’s 9.8 doesn’t know it and will refuse to connect with a Bad SSH2 KexAlgorithms error.
Run the check again:
debug1: kex: algorithm: [email protected]
Post-quantum.
Method 2: Homebrew’s ssh
This gets you a current OpenSSH with ML-KEM.
-
Install it:
brew install openssh -
Make sure it’s the
sshyour shell runs:which sshIf that prints
/usr/bin/ssh, Apple’s is still first. Add this to~/.zshrcand open a new terminal:export PATH="/opt/homebrew/bin:$PATH"which sshshould now print/opt/homebrew/bin/ssh, andssh -Vshould show 10.x. -
Add this to the end of
~/.ssh/config:Host * KexAlgorithms mlkem768x25519-sha256,[email protected],curve25519-sha256,[email protected],ecdh-sha2-nistp256OpenSSH 10 already prefers ML-KEM, so this line is optional. I keep it so the order is explicit.
Run the check again:
debug1: kex: algorithm: mlkem768x25519-sha256
Anything that runs /usr/bin/ssh by its full path, or a GUI app that doesn’t read your shell’s PATH, still uses Apple’s ssh. That’s another reason to keep a ~/.ssh/config line that both versions accept, which is what Method 1 is.
If it’s still not post-quantum
The client offers, but the server has to support it too. If you still see curve25519-sha256 or ecdh-sha2-* after these changes, the server’s OpenSSH is older than 9.0. Check it on the server with ssh -V and update it. On Debian or Ubuntu:
sudo apt update && sudo apt upgrade openssh-server