Linux Tutorials

Find P-256 Keys on Linux and Replace Them: SSH, GPG and TLS

Every 256-bit elliptic curve key on your servers is now on somebody’s replacement list, and nobody has published the attack that put it there. Within four days in early December, an NSA advisory, a Chrome distrust date and a joint statement from Anthropic and OpenAI pushed teams to inventory their SSH, GPG and TLS keys. The claim that P-256 itself is broken still rests on unnamed sources.

Original content from computingforgeeks.com - post 204901

This guide finds P-256 keys on a Linux host with one script, then replaces them: SSH host and user keys, the keys GitHub holds, GPG keys and TLS leaf certificates. It also checks hybrid post-quantum key exchange for SSH and HTTPS. All of it was tested in December 2026 on a fresh Ubuntu 26.04.1 server with OpenSSH 10.2p1 and OpenSSL 3.5.5, and every sshd change passed sshd -t before a reload.

Confirmed facts and the P-256 rumour

Is P-256 broken? Nobody has shown it in public. What is confirmed is that two AI labs found weaknesses they will not describe, and that the NSA and Chrome changed their guidance in the same week. Keep the two apart, because a change ticket that cites a blog rumour gets argued down, while one that cites the NSA advisory doesn’t.

ClaimSourceStatus
Researchers “found weaknesses in some of the cryptography that protects the internet”, which “aren’t an immediate threat to the public”Anthropic and OpenAI joint statement, 5 December 2026Confirmed. No algorithm or curve is named
Both companies pull their own migration forward to the first half of 2027Same statementConfirmed
Inventories should flag “elliptic curves other than P-384 or P-521 for ECDH or ECDSA, EdDSA”NSA advisory PP-26-4956, December 2026Confirmed. P-256 and Ed25519 are implied by exclusion; the NSA never says broken
Chrome stops trusting CA keys that use ECDSA P-256 on 15 March 2027Google blog post by the Chrome Security team, 3 December 2026Confirmed. CA keys only; leaf keys are encouraged, not forced
New RSA keys on GitHub need 3072 bits; ssh-rsa (SHA-1) and DH group exchange go away on 13 January 2027GitHub changelog, 22 September 2026Confirmed
“ECC P-256 was broken”Bruce Schneier, citing “a reliable source”, 3 December 2026Rumour. Unnamed source, no paper, no details
Curve25519 is affected tooOne anonymous source quoted by NBC NewsRumour

Read the NSA sentence carefully. It asks operators to record any elliptic curve other than P-384 or P-521, and it lists EdDSA and DSA in the same breath, so Ed25519 lands in the same bucket even though nobody has named it as weak. A separate line asks for RSA 3K or P-384 as the base size for roots. P-384 and RSA 3072 are therefore the interim the guidance points to, not curves anyone has proven safe. The destination is ML-DSA for signatures and ML-KEM for key exchange, and the joint statement says the NIST post-quantum standards are not affected.

Keys that count and keys that wait

A P-256 key can hide in five places on one host: the SSH host keys, user key files and every authorized_keys, a running ssh-agent, the GnuPG keyring, and certificates under /etc. Most teams only think of the first one. The script below gives each key a verdict using these rules.

  • Any ECDSA key on nistp256 (SSH ecdsa-sha2-nistp256, GPG algorithm 18 or 19 on nistp256, a TLS key on P-256) is marked replace.
  • Ed25519, cv25519 and RSA under 3072 bits are marked review, because the NSA list excludes them but there is no drop-in replacement for all of them yet.
  • ECDSA on P-384 or P-521, RSA at 3072 bits or more and any ML-DSA hybrid key are marked ok.
  • DSA keys are marked replace on sight.
  • FIDO ecdsa-sk and ed25519-sk keys are marked review, because a hardware token has no P-384 option.

Ed25519 sits on review rather than replace for a practical reason. GitHub still recommends it, the hybrid ssh-mldsa44-ed25519 type needs a newer OpenSSH than Ubuntu ships, and FIDO keys only come as ed25519-sk or ecdsa-sk, both 256-bit. So replace P-256 now, and plan Ed25519 for the day ML-DSA reaches your distribution and your Git host.

What a fresh Ubuntu server ships

Start with the defaults, because they decide how many keys you will find before anyone has added a single one. On the lab VM we checked the release, the OpenSSH and OpenSSL builds, and the key and key exchange types ssh supports.

grep PRETTY /etc/os-release
ssh -V
openssl version
ssh -Q key
ssh -Q kex | grep -E "mlkem|sntrup"

The output lists every key type this OpenSSH accepts, followed by the hybrid post-quantum key exchange methods it can offer.

PRETTY_NAME="Ubuntu 26.04.1 LTS"
OpenSSH_10.2p1 Ubuntu-2ubuntu3.8, OpenSSL 3.5.5 27 Jan 2026
OpenSSL 3.5.5 27 Jan 2026 (Library: OpenSSL 3.5.5 27 Jan 2026)
ssh-ed25519
[email protected]
[email protected]
[email protected]
ecdsa-sha2-nistp256
[email protected]
ecdsa-sha2-nistp384
[email protected]
ecdsa-sha2-nistp521
[email protected]
[email protected]
[email protected]
ssh-rsa
[email protected]
sntrup761x25519-sha512
[email protected]
mlkem768x25519-sha256

There is no mldsa entry in the key list. The hybrid ssh-mldsa44-ed25519 signature was only enabled by default in OpenSSH 10.6, according to the OpenSSH release notes, so on this release your choices for new keys are Ed25519, ECDSA on P-384 or P-521, and RSA. Key exchange is in better shape, since mlkem768x25519-sha256 is compiled in and is the client’s first choice.

Ubuntu 26.04.1 with OpenSSH 10.2p1 and OpenSSL 3.5.5, ssh -Q key listing ECDSA nistp256 and no ML-DSA key type

Two more defaults put 256-bit curves on a new box without anyone choosing them. cloud-init generates an ECDSA P-256 host key on first boot, and a GnuPG key made with no algorithm argument is a 256-bit curve as well. We generated one in a throwaway home directory to see which curve it picks.

T=$(mktemp -d); gpg --homedir $T --batch --passphrase "" --quick-gen-key "Default Test <[email protected]>" 2>/dev/null; gpg --homedir $T --list-keys 2>/dev/null | grep -E "^(pub|sub)"; rm -rf $T

GnuPG chose Ed25519 for signing and Curve25519 for encryption, so every default key it makes lands on the review list.

pub   ed25519 2026-12-05 [SC] [expires: 2029-12-04]
sub   cv25519 2026-12-05 [E]

Neither default is wrong today, but both mean a fresh fleet starts with keys the NSA advisory asks you to list. Of the two, cloud-init is the one worth fixing first, because it recreates the P-256 host key on every instance you launch. The rotation section shows the image change that stops it.

The inventory script

The script reports on public material only: host .pub files, each user’s ~/.ssh keys and authorized_keys, the keys loaded in your agent, every GnuPG keyring in a home directory, and PEM certificates under the usual service paths. It does read each .pem file far enough to see whether it holds a certificate, private key files included, but it prints nothing from them. GnuPG runs as the owner of each home directory, so root never writes into a user’s keyring. It exits non-zero while anything is marked replace, so cron or a CI job can alert on it. Open a new file for it.

vim p256-audit.sh

Paste the script exactly as it ran in the lab. It needs only bash, OpenSSH, GnuPG and OpenSSL, which every Ubuntu server already has.

#!/usr/bin/env bash
# p256-audit.sh: inventory SSH, GPG and TLS keys and flag 256-bit curves
# Run: sudo --preserve-env=SSH_AUTH_SOCK ./p256-audit.sh
set -u
[ "$(id -u)" -eq 0 ] || { echo "run as root: sudo $0" >&2; exit 2; }

replace=0
review=0

verdict() { # $1 key type, $2 bits
  case "$1" in
    *MLDSA*|*mldsa*|ML-DSA*) echo ok ;;
    ECDSA-SK) echo review ;;
    ECDSA*|nistp256|P-256) [ "$2" = 256 ] && echo replace || echo ok ;;
    nistp384|nistp521|P-384|P-521) echo ok ;;
    ED25519*|ed25519|cv25519) echo review ;;
    RSA*|rsa) [ "$2" -ge 3072 ] 2>/dev/null && echo ok || echo review ;;
    DSA*|dsa) echo replace ;;
    *) echo review ;;
  esac
}

row() { # class type bits location
  local v
  v=$(verdict "$2" "$3")
  [ "$v" = replace ] && replace=$((replace + 1))
  [ "$v" = review ] && review=$((review + 1))
  printf '%-5s %-11s %-5s %-8s %s\n' "$1" "$2" "$3" "$v" "$4"
}

sshfile() { # class file
  local n=0 bits type
  while read -r bits _ rest; do
    n=$((n + 1))
    type=${rest##*(}; type=${type%)}
    row "$1" "$type" "$bits" "$2:$n"
  done < <(ssh-keygen -lf "$2" 2>/dev/null)
}

printf '%-5s %-11s %-5s %-8s %s\n' CLASS TYPE BITS VERDICT WHERE

for f in /etc/ssh/ssh_host_*_key.pub; do
  [ -e "$f" ] && sshfile host "$f"
done

while IFS=: read -r user _ uid _ _ home _; do
  { [ "$uid" -ge 1000 ] || [ "$uid" -eq 0 ]; } || continue
  [ -d "$home" ] || continue
  for f in "$home"/.ssh/*.pub "$home"/.ssh/authorized_keys "$home"/.ssh/authorized_keys2; do
    [ -f "$f" ] && sshfile user "$f"
  done
  if [ -d "$home/.gnupg" ]; then
    while read -r kind valid bits algo curve keyid; do
      if [ "$valid" = r ]; then
        printf '%-5s %-11s %-5s %-8s %s\n' gpg "$curve" "$bits" revoked "$user $kind $keyid algo=$algo"
      else
        row gpg "$curve" "$bits" "$user $kind $keyid algo=$algo"
      fi
    done < <(runuser -u "$user" -- gpg --homedir "$home/.gnupg" --no-auto-check-trustdb --with-colons --list-keys 2>/dev/null |
      awk -F: '$1=="pub"||$1=="sub"{print $1, $2, $3, $4, ($17==""?"rsa":$17), $5}')
  fi
done < <(getent passwd)

if [ -n "${SSH_AUTH_SOCK:-}" ]; then
  while read -r bits _ rest; do
    type=${rest##*(}; type=${type%)}
    row agent "$type" "$bits" "ssh-agent ${rest% (*}"
  done < <(ssh-add -l 2>/dev/null | grep -v 'no identities')
fi

while read -r f; do
  grep -q 'BEGIN CERTIFICATE' "$f" 2>/dev/null || continue
  text=$(openssl x509 -in "$f" -noout -text 2>/dev/null) || continue
  bits=$(sed -n 's/.*Public-Key: (\([0-9]*\) bit).*/\1/p' <<<"$text" | head -1)
  curve=$(sed -n 's/.*NIST CURVE: \(P-[0-9]*\).*/\1/p' <<<"$text" | head -1)
  algo=${curve:-$(sed -n 's/.*Public Key Algorithm: //p' <<<"$text" | head -1)}
  case "$algo" in rsaEncryption) algo=rsa ;; ED25519) algo=ed25519 ;; esac
  grep -q 'CA:TRUE' <<<"$text" && kind=ca || kind=leaf
  row tls "$algo" "${bits:-?}" "$f ($kind)"
done < <(find -L /etc/ssl /etc/letsencrypt/live /etc/nginx /etc/apache2 /etc/haproxy /etc/pki /opt /srv \
           -path /etc/ssl/certs -prune -o -type f \( -name '*.pem' -o -name '*.crt' -o -name '*.cer' \) -print 2>/dev/null)

echo
echo "replace: $replace  review: $review"
[ "$replace" -eq 0 ]

Make it executable and run it as root. The --preserve-env=SSH_AUTH_SOCK flag lets the root process ask your agent which keys it holds. Without it, sudo drops the socket path and the agent rows are skipped.

chmod +x p256-audit.sh
sudo --preserve-env=SSH_AUTH_SOCK ./p256-audit.sh

On the untouched VM the script found exactly what the defaults predict. The P-256 host key is the only row to replace, and the Ed25519 host key and the Ed25519 login key that cloud-init installed sit on review.

CLASS TYPE        BITS  VERDICT  WHERE
host  ECDSA       256   replace  /etc/ssh/ssh_host_ecdsa_key.pub:1
host  ED25519     256   review   /etc/ssh/ssh_host_ed25519_key.pub:1
host  RSA         3072  ok       /etc/ssh/ssh_host_rsa_key.pub:1
user  ED25519     256   review   /home/mercy/.ssh/authorized_keys:1

replace: 1  review: 2

A real bastion carries more history than that. We added what a few years of use leave behind: an old id_ecdsa key loaded in the agent and copied into a deploy user’s authorized_keys behind a from= restriction. We also added a P-256 GPG key with an encryption subkey and a P-256 TLS leaf for an internal app. The second run caught all of it.

CLASS TYPE        BITS  VERDICT  WHERE
host  ECDSA       256   replace  /etc/ssh/ssh_host_ecdsa_key.pub:1
host  ED25519     256   review   /etc/ssh/ssh_host_ed25519_key.pub:1
host  RSA         3072  ok       /etc/ssh/ssh_host_rsa_key.pub:1
user  ECDSA       256   replace  /home/mercy/.ssh/id_ecdsa.pub:1
user  ED25519     256   review   /home/mercy/.ssh/authorized_keys:1
gpg   nistp256    256   replace  mercy pub BB8AE1FD9A7247F7 algo=19
gpg   nistp256    256   replace  mercy sub B9AF55BCA542CAB7 algo=18
user  ECDSA       256   replace  /home/deploy/.ssh/authorized_keys:1
agent ECDSA       256   replace  ssh-agent mercy@laptop-2023
tls   P-256       256   replace  /etc/ssl/lab/app.example.com.crt (leaf)

replace: 7  review: 2

Every row names a file and a line number, or an agent comment and a GPG key ID, so the fix list writes itself.

p256-audit.sh output flagging seven P-256 keys across SSH host keys, authorized_keys, ssh-agent, GPG and a TLS leaf certificate

Seven rows need replacing, and the deploy row is the one teams miss, because nobody logs in as that user to look at its files. If your services keep certificates somewhere else, add those paths to the find line at the bottom. The defaults cover nginx, Apache, HAProxy, Let’s Encrypt, /opt and /srv, and a path the script does not read is a key it can’t report.

GPG keys by algorithm and curve

GnuPG’s human listing prints the curve name, which is fine for one keyring and useless for a script across fifty home directories. The --with-colons format puts the algorithm and curve in fixed fields, so the audit reads those instead.

gpg --list-keys --keyid-format long
gpg --with-colons --list-keys | grep -E "^(pub|sub)"

Both views of the planted key follow. The primary key signs and certifies, and the subkey handles encryption.

/home/mercy/.gnupg/pubring.kbx
------------------------------
pub   nistp256/BB8AE1FD9A7247F7 2026-12-05 [SC] [expires: 2027-12-05]
      6AFAA3765AE222699B6F2E15BB8AE1FD9A7247F7
uid                 [ultimate] Mercy Lab <[email protected]>
sub   nistp256/B9AF55BCA542CAB7 2026-12-05 [E] [expires: 2027-12-05]
pub:u:256:19:BB8AE1FD9A7247F7:1796510659:1828046659::u:::scESC:::::nistp256:::0:
sub:u:256:18:B9AF55BCA542CAB7:1796510693:1828046693:::::e:::::nistp256::

The colon lines carry the same facts as the human listing, in positions that never move between GnuPG releases.

gpg --with-colons output showing algorithm 19 and 18 with curve nistp256 in field 17

Count the colons from the record type and you reach the fields the script uses. The table covers the values that matter on a typical keyring.

FieldMeaningValues that matter here
1Record typepub primary key, sub subkey
2Validityu ultimate, r revoked, e expired
3Key length in bits256 for any curve key, 3072 or 4096 for RSA
4Public key algorithm1 RSA, 18 ECDH, 19 ECDSA, 22 EdDSA
5Key IDLong key ID
17Curve namenistp256, nistp384, ed25519, cv25519; empty for RSA

Algorithm 19 or 18 with nistp256 in field 17 marks a key to replace. Check field 2 before you act on a row, because a revoked key stays in the listing and does not need any more work. The script prints those rows with the verdict revoked and leaves them out of the count.

TLS leaf certificates on disk and on the wire

Chrome’s March date applies to CA keys, so your own leaf key will not break a browser on that day. It still belongs in the inventory, because Google’s post encourages operators to move server keys off P-256 as well. A single openssl x509 call shows the key type of a certificate on disk.

openssl x509 -in /etc/ssl/lab/app.example.com.crt -noout -text | grep -E "Public Key Algorithm|Public-Key|NIST CURVE"

For the planted certificate, OpenSSL reports a 256-bit key on the P-256 curve.

            Public Key Algorithm: id-ecPublicKey
                Public-Key: (256 bit)
                NIST CURVE: P-256

The same check works against any HTTPS endpoint once you pipe s_client into x509. We pointed it at three large sites to see how common P-256 leaves are in practice.

for h in github.com www.google.com www.cloudflare.com; do printf "%s: " $h; openssl s_client -connect $h:443 -servername $h </dev/null 2>/dev/null | openssl x509 -noout -text | grep -E "NIST CURVE|Public-Key" | tr -s " " | tr "\n" " "; echo; done

Every one of them serves a P-256 leaf certificate today.

github.com:  Public-Key: (256 bit)  NIST CURVE: P-256 
www.google.com:  Public-Key: (256 bit)  NIST CURVE: P-256 
www.cloudflare.com:  Public-Key: (256 bit)  NIST CURVE: P-256 

The local check and the remote loop side by side make the point that your own P-256 leaf is in large company.

openssl x509 showing NIST CURVE P-256 on a local certificate and on the github.com, google.com and cloudflare.com leaf certificates

P-256 leaves are the norm on the public web, which is likely why Chrome started with CA keys, since a handful of CAs can move faster than millions of sites. To check the intermediates and root above your leaf, use the chain test in our Chrome P-256 CA distrust guide. Keep the OpenSSL cheat sheet nearby for the rest of the x509 flags.

Host key rotation without locking clients out

Removing a host key changes what the server proves to every client, and each client that pinned the old key will refuse to connect. Do it in stages so clients learn the new key before the old one disappears.

  1. Generate the new host key next to the P-256 one and add a HostKey line for it, keeping the old key served.
  2. Reload sshd and leave both keys in place while your users and automation connect.
  3. Remove the P-256 key and pin HostKeyAlgorithms once the clients have the new key.
  4. Update known_hosts by hand for anything that never connected during the overlap.

The overlap works because of the client option UpdateHostKeys, which lets a connected client record extra host keys that the server proves it holds. It has limits worth knowing before you count on it. It’s a client setting, the ssh_config manual says it’s on by default only when you haven’t changed UserKnownHostsFile or turned on VerifyHostKeyDNS, and the client learns new keys only after it has authenticated against a key it already trusts. Clients that never log in during the overlap, or run an OpenSSH too old for the option, need the manual step four. So do clients that pin HostKeyAlgorithms to the P-256 type, which learned nothing in our first test, and hosts trusted only through a fleet-wide /etc/ssh/ssh_known_hosts, because keys are learned only for UserKnownHostsFile entries.

Generate the P-384 key first. A distinct file name keeps it from being confused with the key cloud-init created, which matters later when you read sshd -T output.

sudo ssh-keygen -q -t ecdsa -b 384 -N "" -C "" -f /etc/ssh/ssh_host_ecdsa384_key
sudo ssh-keygen -lf /etc/ssh/ssh_host_ecdsa384_key.pub

Check the fingerprint line, which should report a 384-bit ECDSA key.

384 SHA256:sz1XHHGG51sIT3WCe83YKaHIXK1f/BA6kFQl1SCf+r4 no comment (ECDSA)

Ubuntu ships its HostKey lines commented out and reads /etc/ssh/sshd_config.d/*.conf near the top of the main file, where the first value set for an option wins. A drop-in is therefore the clean place for the change, and it survives package upgrades that rewrite sshd_config. Our guide to post-quantum SSH hardening on Ubuntu 26.04 keeps its key exchange settings in a drop-in for the same reason. Start with the overlap version of the file.

sudo vim /etc/ssh/sshd_config.d/10-no-p256.conf

This stage serves the old P-256 key and the new P-384 key side by side, and it keeps both ECDSA types in HostKeyAlgorithms.

# Overlap stage: serve the new P-384 key next to the P-256 key clients already pin
HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_ecdsa384_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKeyAlgorithms ssh-ed25519,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256

Test the file and confirm that sshd loads all four keys.

sudo sshd -t && echo "config OK"
sudo sshd -T | grep -E "^(hostkey|hostkeyalgorithms) "

Four hostkey lines and both ECDSA algorithms mean old clients keep connecting while new ones see the P-384 key.

config OK
hostkeyalgorithms ssh-ed25519,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256
hostkey /etc/ssh/ssh_host_ed25519_key
hostkey /etc/ssh/ssh_host_ecdsa384_key
hostkey /etc/ssh/ssh_host_ecdsa_key
hostkey /etc/ssh/ssh_host_rsa_key

Reload sshd so the overlap takes effect.

sudo systemctl reload ssh

Then let the overlap run. To check that it does its job, we gave a client a known_hosts file holding only the P-256 key and logged in once.

ssh-keyscan -t ecdsa-sha2-nistp256 localhost 2>/dev/null | grep -v "^#" > /tmp/kh && ssh -o UserKnownHostsFile=/tmp/kh -o UpdateHostKeys=yes -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes localhost true && cut -d" " -f2 /tmp/kh; rm /tmp/kh

After a single login the file holds four key types, so this client survives the removal without a warning.

ecdsa-sha2-nistp256
ssh-ed25519
ecdsa-sha2-nistp384
ssh-rsa

When the overlap has run long enough, delete the P-256 key and replace the drop-in with the final version.

sudo rm /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key.pub

The final file serves three host keys, pins the host key algorithms to match, and removes P-256 from the user key types sshd will accept.

# Serve only these host keys; the P-256 key is gone
HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_ecdsa384_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKeyAlgorithms ssh-ed25519,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256

# Refuse ECDSA P-256 user keys and certificates (FIDO sk-ecdsa stays allowed)
PubkeyAcceptedAlgorithms -ecdsa-sha2-nistp256,[email protected]

A leading minus in PubkeyAcceptedAlgorithms removes entries from the built-in list rather than replacing it. FIDO sk-ecdsa-sha2-nistp256 keys stay allowed, because many hardware tokens cannot make anything else. Drop them too if your users already carry ed25519-sk keys. Then test the configuration and read back what sshd will actually use.

sudo sshd -t && echo "config OK"
sudo sshd -T | grep -E "^(hostkey|hostkeyalgorithms|pubkeyacceptedalgorithms) "

The syntax check passes, and the effective settings no longer mention ecdsa-sha2-nistp256 outside the FIDO entries.

config OK
hostkeyalgorithms ssh-ed25519,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256
pubkeyacceptedalgorithms [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
hostkey /etc/ssh/ssh_host_ed25519_key
hostkey /etc/ssh/ssh_host_ecdsa384_key
hostkey /etc/ssh/ssh_host_rsa_key

Trust sshd -T over reading the files, because it shows the merged result of every drop-in and the main config.

sshd -T showing HostKeyAlgorithms and PubkeyAcceptedAlgorithms without ecdsa-sha2-nistp256 after the host key rotation

Reload rather than restart. On Ubuntu, ssh.service runs sshd -t before it sends the reload signal, so a broken file leaves the running daemon alone instead of killing it. After the reload, confirm what the server offers from the outside.

sudo systemctl reload ssh && systemctl is-active ssh
ssh-keyscan -t ecdsa,ed25519 localhost 2>/dev/null | cut -c1-60

The service is still active, and the server now offers P-384 and Ed25519 host keys.

active
# localhost:22 SSH-2.0-OpenSSH_10.2p1 Ubuntu-2ubuntu3.8
localhost ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzOD
# localhost:22 SSH-2.0-OpenSSH_10.2p1 Ubuntu-2ubuntu3.8
localhost ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP/K5rMBzWISdX

Keep your current session open until a second login works. If the new file locks you out, delete 10-no-p256.conf from the console and reload, which brings back the defaults. A typo in a HostKey path doesn’t stop sshd, which logs Unable to load host key and serves the others. It does quietly drop the key you meant to add, so read the ssh-keyscan output rather than trusting the reload.

What clients see after the swap

We also ran the swap once with no overlap, to capture what a client sees when step two is skipped. A client that only knew the old ECDSA key gets the loudest warning OpenSSH has. Forcing the old algorithm shows the new offer from the server instead.

ssh -o BatchMode=yes localhost hostname
ssh -o HostKeyAlgorithms=ecdsa-sha2-nistp256 -o BatchMode=yes localhost hostname

The first command fails host key checking, and the second fails negotiation. That first warning looks exactly like the one a real interception produces, which is why the fingerprint check below matters. The negotiation error at least lists what the server now offers.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:lF+tB+FN0UYe1W67//jtIv/BJzDQPwhTh+wCA3avISM.
Please contact your system administrator.
Add correct host key in /home/mercy/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/mercy/.ssh/known_hosts:1
  remove with:
  ssh-keygen -f '/home/mercy/.ssh/known_hosts' -R 'localhost'
Host key for localhost has changed and you have requested strict checking.
Host key verification failed.
Unable to negotiate with 127.0.0.1 port 22: no matching host key type found. Their offer: ssh-ed25519,ecdsa-sha2-nistp384,rsa-sha2-512,rsa-sha2-256

Note the line number in the Offending ECDSA key message, since it points at the exact entry to remove.

ssh client warning REMOTE HOST IDENTIFICATION HAS CHANGED with an offending ECDSA key in known_hosts after the P-256 host key was removed

Skipping the overlap is what turns a key rotation into a help desk queue. Do not train users to delete the line on reflex, because that habit is exactly what a real man-in-the-middle relies on. Compare the new fingerprint with one you got through a trusted channel, then drop the stale entry and fetch the new key.

ssh-keygen -R localhost
ssh-keyscan -t ed25519 localhost 2>/dev/null | ssh-keygen -lf -

Here the keyscan fingerprint matches the one in the warning above, so it’s safe to accept.

# Host localhost found: line 1
/home/mercy/.ssh/known_hosts updated.
Original contents retained as /home/mercy/.ssh/known_hosts.old
256 SHA256:lF+tB+FN0UYe1W67//jtIv/BJzDQPwhTh+wCA3avISM localhost (ED25519)

Next, prove that the user key restriction works. A login with the old P-256 key should fail, and the server journal should say why it failed.

ssh -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_ecdsa -o IdentitiesOnly=yes -o BatchMode=yes localhost hostname
sudo journalctl -u ssh --since "-2min" --no-pager -o cat | grep -i "nistp256"

The client is told only that its public key was denied, while the journal names the rule that refused it. That journal line is the proof that matters, because sshd checks the algorithm before it reads authorized_keys, so the key is refused even on an account that still trusts it.

mercy@localhost: Permission denied (publickey).
Unable to negotiate with 127.0.0.1 port 49228: no matching host key type found. Their offer: ecdsa-sha2-nistp256 [preauth]
userauth_pubkey: signature algorithm ecdsa-sha2-nistp256 not in PubkeyAcceptedAlgorithms [preauth]

The journal also logged the earlier host key negotiation failure, which is handy when you need to tell a client problem from a key problem.

sshd journal line saying signature algorithm ecdsa-sha2-nistp256 not in PubkeyAcceptedAlgorithms after a P-256 key login is refused

Search for that journal line after a rollout, since every hit is a person or a job still using a P-256 key. Give them the user key steps below before you tighten anything else, or the next complaint will be a broken deploy pipeline rather than a single user.

Images that regenerate the key

On a cloud image, cloud-init recreates host keys for each new instance and brings the P-256 key straight back. It also deletes every /etc/ssh/ssh_host_*key* file on a new instance, so a P-384 key baked into the image is gone before sshd starts. The fix is to choose the types cloud-init generates and make the P-384 key per instance in runcmd.

sudo vim /etc/cloud/cloud.cfg.d/90-ssh-hostkeys.cfg

The try-reload-or-restart verb matters on Ubuntu, where sshd is socket activated and a plain reload fails when no session has started it yet.

# cloud-init deletes /etc/ssh/ssh_host_*key* on a new instance, so the P-384 key is made per instance
ssh_genkeytypes: [ed25519, rsa]
runcmd:
  - [sh, -c, "test -e /etc/ssh/ssh_host_ecdsa384_key || ssh-keygen -q -t ecdsa -b 384 -N '' -C '' -f /etc/ssh/ssh_host_ecdsa384_key"]
  - [systemctl, try-reload-or-restart, ssh]

cloud-init validates a file only when it carries the #cloud-config header, so test a copy that has one.

{ echo "#cloud-config"; cat /etc/cloud/cloud.cfg.d/90-ssh-hostkeys.cfg; } > /tmp/check.cfg && sudo cloud-init schema -c /tmp/check.cfg; rm /tmp/check.cfg

The schema is valid. To act out a new instance, we deleted the P-384 key and ran the two modules that execute runcmd.

sudo rm /etc/ssh/ssh_host_ecdsa384_key /etc/ssh/ssh_host_ecdsa384_key.pub && sudo cloud-init single --name runcmd --frequency always >/dev/null && sudo cloud-init single --name scripts_user --frequency always >/dev/null; sudo ssh-keygen -lf /etc/ssh/ssh_host_ecdsa384_key.pub; ssh-keyscan -t ecdsa localhost 2>/dev/null | grep -v "^#" | cut -c1-60

The key came back as a 384-bit ECDSA key, and sshd serves it without anyone logging in to fix it.

Valid schema /tmp/check.cfg
384 SHA256:Ns/zo//xP42Ok/Btn/yv/1xt+Fu3Fs4XjPy8uNXc6n4 no comment (ECDSA)
localhost ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzOD

One catch: a runcmd list in your instance user data replaces this one instead of merging with it, so copy the two lines into any user data that sets its own runcmd.

On Google Cloud, check the guest agent too, because its built-in defaults include host_key_types = ecdsa,ed25519,rsa with set_host_keys = true.

grep -rs host_key /etc/default/instance_configs.cfg /etc/default/instance_configs.cfg.template /etc/default/instance_configs.cfg.distro; dpkg -l google-guest-agent | tail -1; ls /etc/ssh/ssh_host_*_key.pub

On our Ubuntu image the main file carries those defaults, but the .distro file sets set_host_keys = false.

/etc/default/instance_configs.cfg:host_key_types = ecdsa,ed25519,rsa
/etc/default/instance_configs.cfg:set_host_keys = true
/etc/default/instance_configs.cfg.distro:set_host_keys = false
ii  google-guest-agent 20260819.00+~20260819.00-0ubuntu2~26.04.0~ppa4 amd64        Google Compute Engine Guest Agent
/etc/ssh/ssh_host_ecdsa384_key.pub
/etc/ssh/ssh_host_ed25519_key.pub
/etc/ssh/ssh_host_rsa_key.pub

The agent reads the .distro and .template files after the main one, according to its configuration loader, so cloud-init owns host keys here. Images where the agent does create them need host_key_types = ed25519,rsa under [InstanceSetup], set in the last of those three files that defines the key, since a later file silently overrides an earlier one. Bake both changes into the template before you rebuild anything, or every autoscaled instance undoes the rotation on first boot.

User keys, authorized_keys and GitHub

User keys are spread over laptops, agents and every server that trusts them, so the order matters. Add the new key everywhere, prove it logs in, and only then remove the old one. Generate an Ed25519 key with the same command our SSH key authentication guide uses.

ssh-keygen -t ed25519 -C mercy@laptop-2026 -N "" -f ~/.ssh/id_ed25519

Use a passphrase on a real workstation. The lab key has none so the steps could run unattended.

Generating public/private ed25519 key pair.
Your identification has been saved in /home/mercy/.ssh/id_ed25519
Your public key has been saved in /home/mercy/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:btlJfbQq5vEKrp/VGvy3NZMVS44hCybZf+lg2fJZB44 mercy@laptop-2026
The key's randomart image is:
+--[ED25519 256]--+
|                 |
|        o        |
|       o + . .oo |
|        o o.=+*oo|
|        S .BE=++o|
|       . =.o*oo +|
|        = X o+ +.|
|       o * B  ..o|
|      .o+ +.o... |
+----[SHA256]-----+

Append the public key to authorized_keys and log in with that key alone. Forcing IdentitiesOnly matters here, because otherwise the agent could offer a leftover key and make the test pass for the wrong reason.

cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys && ssh -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes localhost "echo login with \$(ssh-keygen -lf ~/.ssh/id_ed25519.pub | cut -d\" \" -f4)"

The login succeeds with the Ed25519 key. Only delete anything once that line prints, since a failed test with the old key already removed means a console session to recover.

login with (ED25519)

Now remove the old key from your own file, and swap it in place in the deploy account. On our bastion the first sed found nothing to delete, because the old key had only ever been trusted by deploy, but on most hosts it does.

Replacing only the key text in the deploy file keeps the from= restriction in front of it.

sed -i "/ecdsa-sha2-nistp256 .* mercy@laptop-2023/d" ~/.ssh/authorized_keys
sudo sed -i "s|ecdsa-sha2-nistp256 [^ ]* mercy@laptop-2023|$(cat ~/.ssh/id_ed25519.pub)|" /home/deploy/.ssh/authorized_keys
sudo cut -c1-60 /home/deploy/.ssh/authorized_keys

Reading the line back shows the restriction survived and the key is now Ed25519.

from="10.0.1.0/24" ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPDFl

Finally, remove the old key from the agent and delete both files, so nothing can offer it again.

ssh-add -d ~/.ssh/id_ecdsa && rm ~/.ssh/id_ecdsa ~/.ssh/id_ecdsa.pub

The agent confirms the identity is gone.

Identity removed: /home/mercy/.ssh/id_ecdsa ECDSA (mercy@laptop-2023)

Repeat the same swap on every host the old key was trusted on, then run the audit again on each. A key that’s gone from your laptop but still sits in a forgotten authorized_keys remains a way in for whoever holds the private half, so the server side is the part to verify.

GitHub, GitLab and other Git hosts

Add the new public key in the SSH key settings of your Git host first, test a clone or ssh -T, and then delete the old ECDSA entry. GitHub’s September changelog sets the rules: RSA keys uploaded after 14 October 2026 must be at least 3072 bits, and Ed25519 is the recommended type. The changelog adds no post-quantum authentication key type. If your policy follows the NSA list strictly, use ssh-keygen -t ecdsa -b 384 or RSA 3072 instead of Ed25519.

Hardware keys are the awkward case. A YubiKey makes ed25519-sk keys on firmware 5.2.3 or later and ecdsa-sk keys otherwise, and both are 256-bit curves. They also keep the private key off the disk, which still matters more than the curve debate, so leave them on the review list rather than swapping them for software keys.

Replacing a P-256 GPG key

A GPG key can’t be moved to a new curve, so the fix is a new key plus a revocation for the old one. GnuPG writes a revocation certificate when it creates a key, with a leading colon that guards against accidental import. Strip the colon and import it.

sed "s/^:-----BEGIN/-----BEGIN/" ~/.gnupg/openpgp-revocs.d/6AFAA3765AE222699B6F2E15BB8AE1FD9A7247F7.rev | gpg --import

GnuPG reports one new revocation, so the old key is now revoked locally.

gpg: key BB8AE1FD9A7247F7: "Mercy Lab <[email protected]>" revocation certificate imported
gpg: Total number processed: 1
gpg:    new key revocations: 1
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: next trustdb check due at 2027-12-05

Create the replacement with the same user ID. The --yes flag is required, because GnuPG refuses a second key for an existing user ID without it.

gpg --batch --yes --passphrase "" --quick-gen-key "Mercy Lab <[email protected]>" rsa3072 default 1y

GnuPG warns about the duplicate, creates the key anyway and stores a revocation certificate for it. The lab key has an empty passphrase so the run could be scripted; drop --batch --passphrase on a real keyring and let GnuPG prompt you.

gpg: A key for "Mercy Lab <[email protected]>" already exists
gpg: creating anyway
gpg: revocation certificate stored as '/home/mercy/.gnupg/openpgp-revocs.d/3B0C46788E1417899AF2ECD995CAAC36428360C1.rev'

Add an RSA 3072 encryption subkey and list both keys in the colon format.

gpg --batch --passphrase "" --quick-add-key 3B0C46788E1417899AF2ECD995CAAC36428360C1 rsa3072 encr 1y && gpg --with-colons --list-keys | grep -E "^(pub|sub)"

Both P-256 records now show r in field 2, and the new key and subkey are RSA 3072.

pub:r:256:19:BB8AE1FD9A7247F7:1796510659:1828046659::-:::sc:::::nistp256:::0:
sub:r:256:18:B9AF55BCA542CAB7:1796510693:1828046693:::::e:::::nistp256::
pub:u:3072:1:95CAAC36428360C1:1796510851:1828046851::u:::scESC::::::23::0:
sub:u:3072:1:0AF09772CC1FFA5F:1796510866:1828046866:::::e::::::23:

Publish the revoked key wherever people fetch it, a keyserver or your web key directory, so their copies learn of the revocation. Then point Git commit signing and anything else that names the old key ID at the new fingerprint. If you skip that, signatures keep coming from the revoked key and start failing verification for everyone who refreshed.

Hybrid post-quantum key exchange in SSH

Replacing a signing key protects future logins, but recorded traffic depends on the key exchange, which is the half the harvest-now, decrypt-later threat targets. GitHub turned on mlkem768x25519-sha256 in October, and a verbose connection shows what you actually negotiate.

ssh -vv -T -o StrictHostKeyChecking=accept-new -i ~/.ssh/id_ed25519 [email protected] 2>&1 | grep -E "kex: algorithm|kex: host key algorithm|Server host key|Permission denied|Hi "

We used a throwaway key that is not registered with GitHub, so the login is refused. The key exchange happens before authentication, so the lines we wanted are already there.

debug1: kex: algorithm: mlkem768x25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: Server host key: ssh-ed25519 SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
[email protected]: Permission denied (publickey).

The kex: algorithm line is the one to look for, and here it names the ML-KEM hybrid.

ssh -vv against github.com negotiating mlkem768x25519-sha256 key exchange with an ssh-ed25519 host key

GitHub still accepts classical key exchange as well. On 6 December, forcing curve25519-sha256 or diffie-hellman-group-exchange-sha256 still got as far as authentication, and the second one is due to go on 13 January 2027.

ssh -T -o KexAlgorithms=curve25519-sha256 -i ~/.ssh/id_ed25519 [email protected] 2>&1 | head -4
ssh -T -o KexAlgorithms=diffie-hellman-group-exchange-sha256 -i ~/.ssh/id_ed25519 [email protected] 2>&1 | head -4

Both reach the same refusal, which means the key exchange completed.

[email protected]: Permission denied (publickey).
[email protected]: Permission denied (publickey).

On your own servers, the client tells you when a session isn’t protected. To see it, start a second sshd on port 2222 that offers only classical key exchange.

sudo /usr/sbin/sshd -p 2222 -o KexAlgorithms=curve25519-sha256 -o PidFile=/run/sshd-2222.pid

Then connect to it with and without the warning, and stop it afterwards with sudo kill $(cat /run/sshd-2222.pid).

ssh -p 2222 -i ~/.ssh/id_ed25519 localhost hostname
ssh -p 2222 -o WarnWeakCrypto=no -i ~/.ssh/id_ed25519 localhost hostname

The client prints a warning but still connects, and WarnWeakCrypto=no silences it.

** WARNING: connection is not using a post-quantum key exchange algorithm.
** This session may be vulnerable to "store now, decrypt later" attacks.
** The server may need to be upgraded. See https://openssh.com/pq.html
bastion-01
bastion-01

That warning helps while you inventory, and it is easy to ignore afterwards. To enforce hybrid key exchange on the server instead, add a second drop-in.

sudo vim /etc/ssh/sshd_config.d/20-pq-kex.conf

It keeps only the ML-KEM and Streamlined NTRU Prime hybrids.

# Hybrid post-quantum key exchange only; clients older than OpenSSH 8.9 cannot connect
KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,[email protected]

OpenSSH has offered the NTRU Prime hybrid by default since 8.9, so clients older than that are refused. The bigger risk is everything that isn’t OpenSSH: Paramiko-based tools, older Go and Java SSH libraries and network appliances often support neither hybrid, so check your oldest automation before you reload. Then test, reload, and try a classical-only client against the server.

sudo sshd -t && sudo systemctl reload ssh && sudo sshd -T | grep "^kexalgorithms"
ssh -o KexAlgorithms=curve25519-sha256 -i ~/.ssh/id_ed25519 localhost hostname
ssh -i ~/.ssh/id_ed25519 localhost hostname

The pinned list is in effect, the classical client is refused, and a default client connects. The refused client prints the full server offer in its error, so the cause is easy to spot when that error lands in a support ticket.

kexalgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,[email protected]
Unable to negotiate with 127.0.0.1 port 22: no matching key exchange method found. Their offer: mlkem768x25519-sha256,sntrup761x25519-sha512,[email protected],ext-info-s,[email protected]
bastion-01

The screenshot puts the classical warning and the pinned refusal next to each other.

OpenSSH post-quantum key exchange warning from a classical server and a pinned KexAlgorithms list refusing curve25519-sha256

Our post-quantum SSH hardening guide covers the cipher and MAC settings that belong next to this drop-in. Pin key exchange only on servers whose clients you control, because a refused vendor appliance is harder to fix than a warning.

Reissuing a TLS leaf on P-384

A leaf certificate cannot change key type in place, so you need a new key and a new certificate. For a public site, ask your ACME client for a P-384 key, which in certbot is --key-type ecdsa --elliptic-curve secp384r1. The lab app uses a self-signed leaf, so we replaced it directly and kept it from being marked as a CA.

sudo openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:secp384r1 -nodes -keyout /etc/ssl/private/app.example.com.key -out /etc/ssl/lab/app.example.com.crt -days 90 -subj /CN=app.example.com -addext subjectAltName=DNS:app.example.com -addext basicConstraints=critical,CA:FALSE
openssl x509 -in /etc/ssl/lab/app.example.com.crt -noout -text | grep -E "Public-Key|NIST CURVE"

The new certificate carries a 384-bit P-384 key. Reload whatever serves it afterwards, because nginx and HAProxy keep the old certificate in memory until they’re told to read the files again.

                Public-Key: (384 bit)
                NIST CURVE: P-384

With the certificate loaded by a test server on port 8443, s_client confirms both halves of the handshake. You want the P-384 signature and the hybrid ML-KEM group in the same output.

openssl s_client -connect localhost:8443 -servername app.example.com -groups X25519MLKEM768 </dev/null 2>/dev/null | grep -E "Negotiated TLS1.3 group|Peer signature type|Server public key|^New,"

The peer signs with ECDSA on secp384r1, and TLS 1.3 negotiated X25519MLKEM768.

Peer signature type: ecdsa_secp384r1_sha384
Negotiated TLS1.3 group: X25519MLKEM768
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 384 bit

The Server public key is 384 bit line confirms the client received the new certificate rather than a cached one.

openssl s_client negotiating X25519MLKEM768 with a reissued P-384 leaf certificate and ecdsa_secp384r1_sha384 signature

Public endpoints vary more than you might expect. We offered three sites the hybrid group first, with X25519 as a fallback, and then offered GitHub the hybrid alone.

for h in www.google.com www.cloudflare.com github.com; do printf "%-20s " $h; openssl s_client -connect $h:443 -servername $h -groups X25519MLKEM768:X25519 </dev/null 2>/dev/null | grep -E "Negotiated TLS1.3 group" || echo "no TLS 1.3 group line"; done
openssl s_client -connect github.com:443 -servername github.com -groups X25519MLKEM768 </dev/null 2>&1 | grep -E "alert|Negotiated TLS1.3 group"

Google and Cloudflare chose the hybrid. The github.com HTTPS endpoint printed no TLS 1.3 group line and rejected an ML-KEM-only offer with alert 40.

www.google.com       Negotiated TLS1.3 group: X25519MLKEM768
www.cloudflare.com   Negotiated TLS1.3 group: X25519MLKEM768
github.com           no TLS 1.3 group line
409702AE2F760000:error:0A000410:SSL routines:ssl3_read_bytes:ssl/tls alert handshake failure:../ssl/record/rec_layer_s3.c:918:SSL alert number 40
Negotiated TLS1.3 group: <NULL>

So on the same day, GitHub’s SSH endpoint spoke ML-KEM and its HTTPS endpoint did not. Test each protocol separately rather than assuming one vendor moves everything at once. If you run nginx, Apache or HAProxy yourself, the steps to offer the hybrid group are in our post-quantum TLS guide.

Proof the rotation held

Run the audit again after every change, because it’s the one check that covers all five places at once. Print the exit status as well, since that’s what cron will act on.

sudo --preserve-env=SSH_AUTH_SOCK ./p256-audit.sh; echo "exit status: $?"

After the rotation above, the same script on the same host returned this.

CLASS TYPE        BITS  VERDICT  WHERE
host  ECDSA       384   ok       /etc/ssh/ssh_host_ecdsa384_key.pub:1
host  ED25519     256   review   /etc/ssh/ssh_host_ed25519_key.pub:1
host  RSA         3072  ok       /etc/ssh/ssh_host_rsa_key.pub:1
user  ED25519     256   review   /home/mercy/.ssh/id_ed25519.pub:1
user  ED25519     256   review   /home/mercy/.ssh/authorized_keys:1
user  ED25519     256   review   /home/mercy/.ssh/authorized_keys:2
gpg   nistp256    256   revoked  mercy pub BB8AE1FD9A7247F7 algo=19
gpg   nistp256    256   revoked  mercy sub B9AF55BCA542CAB7 algo=18
gpg   rsa         3072  ok       mercy pub 95CAAC36428360C1 algo=1
gpg   rsa         3072  ok       mercy sub 0AF09772CC1FFA5F algo=1
user  ED25519     256   review   /home/deploy/.ssh/authorized_keys:1
tls   P-384       384   ok       /etc/ssl/lab/app.example.com.crt (leaf)

replace: 0  review: 5
exit status: 0

Compare it with the planted run earlier, where the same host had seven rows to replace.

p256-audit.sh after rotation reporting replace 0 with revoked GPG keys and a P-384 TLS leaf, exit status 0

Nothing is left to replace and the exit status is zero. The five review rows are the Ed25519 keys we chose to keep, and the revoked GPG keys are reported but not counted. Run it from cron on every host and alert on a non-zero exit, so a P-256 key copied back from an old laptop shows up the next morning. The script only reads public files, so a nightly run is cheap, while a key nobody knew about can sit in an authorized_keys file for years.

Errors and fixes

Each of these came up during the lab run. Every message is quoted the way the tool prints it, so you can paste it into a search.

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

The client still has the old P-256 host key pinned in known_hosts. Confirm the new fingerprint through a channel you trust, then run ssh-keygen -R <host> and reconnect. A long overlap with both keys served prevents most of these, because clients pick up the new key on their own.

no matching host key type found

The client asked for ecdsa-sha2-nistp256 only, usually because a HostKeyAlgorithms line in its ~/.ssh/config names that one type. Remove the line or list the types in the server offer, which the error message prints for you.

signature algorithm ecdsa-sha2-nistp256 not in PubkeyAcceptedAlgorithms

This line appears in the server journal, while the client only sees Permission denied (publickey). The user is still offering a P-256 key, so give them the user key steps and leave the restriction in place.

no matching key exchange method found

A client without ML-KEM or Streamlined NTRU Prime support hit the pinned KexAlgorithms list. Upgrade the client. If that is not possible yet, add curve25519-sha256 back to the server list and accept the post-quantum warning until it is.

gpg: A key for “…” already exists

GnuPG refuses --quick-gen-key for a user ID that is already on the keyring. Add --yes and it creates the key anyway, as the GPG section shows.

ssl/tls alert handshake failure, SSL alert number 40

The server supports none of the groups you offered. We saw it when only X25519MLKEM768 was offered to github.com, and adding X25519 as a fallback in the -groups list shows which group the server does pick.

connection is not using a post-quantum key exchange algorithm

The server negotiated classical key exchange. It is a warning, not a failure, so fix it by upgrading the OpenSSH on the server. Do not silence it with WarnWeakCrypto=no in a shared configuration, because then nobody sees the next server that regresses.

Dates to plan around

None of these dates says P-256 fails on a given day. They are the points where something you depend on changes its behaviour.

  • GitHub ran a brownout of ssh-rsa (SHA-1) signatures and diffie-hellman-group-exchange-sha256 on 4 November 2026 and runs another on 9 December 2026.
  • GitHub removes both on 13 January 2027, so old clients that need either one stop working that day.
  • Chrome intends to stop trusting P-256 CA keys on 15 March 2027, which reaches you through the chain your CA issues.
  • Anthropic and OpenAI move their own systems in the first half of 2027, and other vendors’ migrations are likely to fall in the same window.

Put the GitHub date first on your calendar, because it is the nearest one, and ask your CA about its plan for the Chrome date now. The vendor dates are a reason to finish your inventory early rather than a deadline you control, so treat them as the outer edge of the plan.

P-256 audit checklist

Run through this list on each host after the rotation, and attach the results to the change record so the next audit starts from a known state.

  1. p256-audit.sh exits 0 and lists no replace rows.
  2. sshd -T shows no ssh_host_ecdsa_key entry and no ecdsa-sha2-nistp256 in hostkeyalgorithms.
  3. pubkeyacceptedalgorithms lists no ecdsa-sha2-nistp256 outside the FIDO entries.
  4. ssh-keyscan from another host returns only the key types you planned to serve.
  5. The image’s cloud-init configuration generates no ECDSA host key on a new instance.
  6. No user’s authorized_keys, agent or ~/.ssh holds a P-256 key, service accounts included.
  7. Your Git host lists only the new keys under each account.
  8. Every P-256 GPG key shows r in field 2, and its revocation is published.
  9. Every TLS leaf you control reports NIST CURVE: P-384 or RSA 3072 or larger.
  10. ssh -v to your servers and to your Git host shows mlkem768x25519-sha256.
  11. The sshd journal has no new not in PubkeyAcceptedAlgorithms lines for a week.

Keep the Ed25519 review rows on a ticket of their own. When your distribution ships an OpenSSH with ML-DSA signatures and your Git host accepts them, that ticket becomes the next rotation, and this same script tells you where to start.

Keep reading

Java4Shell (CVE-2026-114938): Find and Patch Vulnerable JVMs Security Java4Shell (CVE-2026-114938): Find and Patch Vulnerable JVMs UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Security UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 nginx HTTP/2 RCE CVE-2026-123007: Check, Disable HTTP/2, Patch Security nginx HTTP/2 RCE CVE-2026-123007: Check, Disable HTTP/2, Patch Join Fedora 45 / 44 to FreeIPA: ipa-client-install, SSSD, sudo Fedora Join Fedora 45 / 44 to FreeIPA: ipa-client-install, SSSD, sudo ARTEX AI Penetration Testing: Self-Hosted Install Guide AI ARTEX AI Penetration Testing: Self-Hosted Install Guide Best CISA Books for the Certified Information Systems Auditor Exam Books Best CISA Books for the Certified Information Systems Auditor Exam

Leave a Comment

Press ESC to close