Back Original

How to find and upgrade SSH and PGP keys using P‑256, ED25519, and Curve25519

Probably the strongest evidence that there exists an expensive break of 256-bit elliptic curves arrived yesterday, Google announced that root and intermediate CA certificates (read: "long-lived") that used the ECDSA P-256 curve would not be accepted after March 17, 2027. This is ~100 days (a very short timespan for anything that affects "all CAs") and would affect ~25% of all web traffic, which is not something one would do for no reason.

Speaking of long-lived keys, SSH and PGP keys are similar to root and intermediate CA certificates in that way. I don't think this is a "drop everything and do this now" situation, but the timeline of "next three months" seems prudent. Here's how to find keys that you should upgrade on your system:

ssh-add -L | grep -E '^[^ ]*(nistp256|25519)' | grep -vE '^[^ ]*ml-?dsa'

This command finds P-256, ED25519, and Curve25519 keys that are registered with your SSH agent. The same is true for PGP keys, if you have those on your system:

gpg -k --keyid-format long | grep -E '^(pub|sub|sec|ssb)[#>]? +[^/ ]*(25519|256)' | grep -viE 'ky[0-9]|dil[0-9]|ml-?kem|ml-?dsa'

Here's what running these commands returns on my computer as of this morning:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINzmaKr8fHsDNPeht128GMbA+fe53pjYbPgS0V8dhjfK SSH

Seems that my PGP key is using RSA-4096 which is not a concern for today. Okay, so let's upgrade the SSH key now. Unfortunately I'm not able to generate quantum-safe SSH keys yet (ssh -Q key | grep -i mldsa is empty), Ubuntu 26.04.1 ships 10.2p1, but support for mldsa44-ed25519 in OpenSSH 10.6p2.

GitHub doesn't support ML-DSA for SSH yet (SSH ML-DSA is still an IETF draft). If GitHub supports mldsa44-ed25519 SSH keys at the time you're reading this then use ssh-keygen -t mldsa44-ed25519 ..., otherwise proceed with P-384 or RSA-4096.

You can generate a P-384 elliptic curve SSH key like so:

ssh-keygen -t ecdsa -b 384 -C '(comment)' (...options for encryption like '-a 100')

Note that if you're generating a new key with a hardware key (-sk suffix) please check that the generated key is actually using P-384, OpenSSH will ignore the -b option for hardware keys. From the OpenSSH -b manpage:

"ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the -b flag will be ignored."

After you generate the file locally, register the SSH key with your password manager and remove the files from your filesystem. Funnily enough, this is how I discovered that Bitwarden only supports ED25519 and RSA SSH keys. It pains me to say that having an RSA-4096 key is a decent stop-gap at this point until you can upgrade to a quantum-safe key across both your hardware key / password manager and services you're using the key with.

After you've generated and tested using your new key then don't forget to unregister your now unused key with services and removing the key from your SSH agent, computer, etc.

Thank you to William Woodruff for reviewing this document prior to publication.

Thanks for reading!

Send me an email or message on Mastodon or Bluesky. The best way to support my writing is sharing links with your friends or colleagues. If you’d like to be notified of future publications either subscribe via RSS or add your email to the newsletter: