One seed to rule them all

Yesterday the NSA asked the people who run US national security systems to move faster on post-quantum cryptography. I can update my laptop this afternoon. For my old server, I have to wait for the vendor. Until then, I still need to log in to it.

Filippo Valsorda thinks we should move away from 256-bit elliptic curves sooner than we planned. That includes the curve my ~/.ssh/id_ed25519 key uses. If I put that public key on ten servers and someone finds a way to forge a signature for it, they can log in as me on all ten. I'd rather give each server its own key. If the algorithm itself turns out to be weak, I'll still need to move those servers to a stronger one.

I used to get by with one type of SSH key. Now the key I need depends on the server. I built ssh-seed so I can keep one seed and give each server its own key by using its hostname. The seed is the person. The keys are the cosmetics.

The cosmetics

What the server accepts What I ask ssh-seed for
The ML-DSA-44 and Ed25519 hybrid mldsa44-ed25519 (the default). The server checks both signatures.
A P-384 ECDSA key p384. I use this on older servers that support P-384.
A 4096-bit RSA key rsa4096. I can use RSA while I wait for an older server to support post-quantum signatures.
The ML-DSA-87 and P-384 hybrid mldsa87-p384. Both the client and the server need to support this hybrid.

I make one 32-byte seed. I've already set up my secret, so I run this command once. I back up the encrypted store and keep the passphrase I need to open it.

head -c 32 /dev/urandom | secret set seed

I use a hybrid key on my updated server. If I add another server that supports hybrid keys, I pass its hostname to ssh-seed. My old server can still use P-384.

secret show seed | ssh-seed updated-server
secret show seed | ssh-seed another-server
secret show seed | ssh-seed p384 my-old-server

I add each public key to ~/.ssh/authorized_keys only on the server it's for. I can print it when I need it, so I don't keep a .pub file on my laptop.

This way I can start using hybrid keys today while I wait for my old server's update. If someone gets the private key for another-server, I only need to remove the matching public key from one server.

To log in to my old server, I use -s to send the private key to my SSH agent. The agent keeps it for ten minutes, so I can log in without saving the private key to a file.

secret show seed | ssh-seed p384 -s my-old-server | ssh-add -t 600 -

If my old server needs RSA, I use rsa4096 in place of p384 both when I print the public key and when I load the private key.

Where the keys come from

The only name I pass to ssh-seed is the hostname I use to log in. It hashes that name, combines the hash with my seed using HKDF-SHA-256, and makes a key for the algorithm I chose. Anyone who gets my seed can make the keys for any hostname.

When my old server gets its update, I can keep the name my-old-server and drop p384 from the command. I'll add the hybrid public key to authorized_keys and test a login with it before I remove the old key.

I don't know how much time we have to replace our old keys. After yesterday's warning, I expect the advice to change quickly as we learn more. My servers will still get their updates on different days. I can start with the ones I can update this afternoon.

Thanks for reading, and good luck to all of us in this new post-quantum world :)