Infrastructure engineering for East Africa's operators, platforms and regulators See the work →
SSH Certificates vs authorized_keys: What Revoking Misses
Linux 6 min read

SSH Certificates vs authorized_keys: What Revoking Misses

SSH certificates vs authorized_keys, tested on Ubuntu 26.04: the bare key that beat a revoked certificate, the open session, and a missing KRL.

CE
CloudSpinx Engineering
Infrastructure Engineering, Virtualization, Networking, Automation
26 November 2026
ssh certificatesauthorized_keysopensshssh ca

On Ubuntu 26.04 sshd asks one question of every key before it cares whether the key sits in authorized_keys or carries a certificate: is it in the revoked keys file? Only after that does it check who signed the certificate, whether the account accepts the names inside it, and whether the certificate is in date, in that order, as OpenSSH's own auth2-pubkey.c lays it out. That order settles most of the SSH certificates vs authorized_keys question, and it explains the three gaps we found when we tried to take access away.

We built two Ubuntu 26.04 servers in our Proxmox lab, OpenSSH 10.2p1, with a user CA, a host CA, a shared deploy account and two named users, then revoked, expired and broke things and read the server log each time. Certificates are worth it once a team of more than a few people touches more than a few servers. They did not, on their own, lock out a person whose bare key was still in an authorized_keys file, end a session already open, or survive the revocation file going missing, which refused every key on the server, the admin's included.

What sshd checks before it accepts a key, in order
What sshd checks before it accepts a key, in orderA flow of the checks OpenSSH 10.2 makes on a key offered for login. The revoked keys file is read first, for certificates and bare keys alike: a listed key is refused, and a missing file refuses every key. A certificate then needs a trusted CA signature, a principal the account lists and a validity window that includes now. A bare key only needs a line in authorized_keys. Once a connection is accepted, nothing is checked again for that connection.Client offers a key or a certificateIn /etc/ssh/revoked_keys?read first, for certificates and bare keysListed: refusedMissing: all refusedCERTIFICATEBARE KEYSigned by a trusted user CA?TrustedUserCAKeysName in auth_principals/%u?else: no authorized principalValid right now?else: expired, or not yet validLine in authorized_keys?no principals, no expiry, no serialAccepted: the connection is upNot checked again for this connectionopen sessions and ControlMaster sessions outlived expiry and revocation
A bare key skips every certificate check, so a serial revocation does not stop a key that is still in authorized_keys. Revoking the public key itself blocks both paths at the first gate.

In our lab an open session and a ControlMaster connection kept working after the certificate expired and after the key was revoked, until the session was terminated and the master told to exit.

SSH certificates: the server side

Four lines in a drop-in, the same on every server:

# /etc/ssh/sshd_config.d/50-user-ca.conf
TrustedUserCAKeys /etc/ssh/user_ca.pub
AuthorizedPrincipalsFile /etc/ssh/auth_principals/%u
RevokedKeys /etc/ssh/revoked_keys
HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub

/etc/ssh/auth_principals/deploy lists the people allowed into deploy, one name a line. A new person is then one name in that file, pushed by whatever manages your config, and a signature on their existing public key. Nobody copies a key to a server:

$ ssh-keygen -s user_ca -I wanjiru@cloudspinx -n wanjiru -z 101 -V -5m:+8h wanjiru.pub
$ ssh -i wanjiru [email protected] 'echo $(whoami)@$(hostname)'
deploy@ailab-e10277-srv1

The server logged it as Accepted publickey for deploy ... ED25519-CERT ... ID wanjiru@cloudspinx (serial 101), which is the first practical win: the log names the person, not just a fingerprint on a shared account.

Two flags in that command matter more than they look. Leave out -V and the ssh-keygen manual says the certificate is valid "from the Unix Epoch to the distant future", which is an authorized_keys entry with extra steps. And start the window a few minutes in the past. A certificate signed for +10m was refused with Certificate invalid: not yet valid, which is what a server whose clock runs behind the signing laptop does to a certificate that starts now.

A name the account does not list gets the same Permission denied (publickey) on the client as a wrong key. Only the server log says why:

error: Refusing certificate ID "wanjiru@cloudspinx" serial=101 signed by ED25519 CA SHA256:bl1y...: Certificate does not contain an authorized principal

Revoking a certificate by serial, and the key it did not stop

Revocation goes in a KRL, a compact binary list sshd reads on every login. We revoked serial 101, copied the file to both servers in 3.7 seconds with no sshd reload, and the next login on each was refused:

$ ssh-keygen -k -u -f revoked.krl -s user_ca.pub revoke.txt
$ ssh -i wanjiru [email protected] true
[email protected]: Permission denied (publickey).

Then we put Wanjiru's bare public key back in deploy's authorized_keys, the way it would be on a server where the move to certificates never quite finished. She was straight back in:

error: Authentication key ED25519-CERT SHA256:v9lW... revoked by file /etc/ssh/revoked_keys
Accepted publickey for deploy from 198.51.100.7 port 53250 ssh2: ED25519 SHA256:v9lW...

A serial revokes that certificate and nothing else. Her client offered the certificate, was refused, offered the plain key and found it listed. Revoking the public key itself is what closes both doors, and ssh-keygen -Q confirms it:

$ ssh-keygen -k -u -f revoked.krl wanjiru.pub
$ ssh-keygen -Q -f revoked.krl wanjiru.pub wanjiru-cert.pub
wanjiru.pub (wanjiru@laptop): REVOKED
wanjiru-cert.pub (wanjiru@laptop): REVOKED

So when someone leaves, revoke their key, not their serial. The same goes for a private key that turned up in a repository: rewriting the git history hides it, revoking the key is what stops it working. Keep serials for a certificate you reissued, where the person stays and the old certificate should not.

Expired or revoked, an open SSH session keeps running

We signed Otieno a certificate good for four minutes, started a session printing a line every ten seconds, and opened an OpenSSH ControlMaster connection, the multiplexed connection that ControlMaster auto and ControlPersist in ~/.ssh/config keep open between commands. Six seconds after the certificate expired, a new login was refused with Certificate invalid: expired. The open session kept printing. A new session through the ControlMaster, started after expiry, opened without a question:

$ ssh -o ControlPath=cm-%r@%h [email protected] 'echo new session over the existing master at $(date +%T)'
new session over the existing master at 10:57:01

Revoking the key did the same with a fresh certificate: direct logins refused at once, the master still opening sessions until it was told to exit. Expiry and revocation are checked when a connection authenticates, and a ControlMaster authenticated once. Short-lived certificates therefore cap how long someone can start new connections, not how long they stay in.

Ending what is open is a separate step on each server. sudo loginctl terminate-user otieno closed the running session 42 seconds after expiry, the client printing Connection to 192.0.2.11 closed by remote host.

If someone left this week and their access has to be gone today, message us on WhatsApp at +254 713 403 044 with how many servers they could reach and how they logged in, and we will tell you what to run first.

A missing RevokedKeys file locks everyone out

The sshd_config manual says it plainly: if the revoked keys file "is not readable, then public key authentication will be refused for all users". We moved it aside on one server. The admin's own plain key, in its own authorized_keys, was refused along with every certificate:

error: Error checking authentication key ED25519 SHA256:padg... in revoked keys file /etc/ssh/revoked_keys: No such file or directory

We got back in through the Proxmox guest agent. Without console access of some kind, you would not have. A config management run that writes RevokedKeys into the drop-in and reloads sshd before the file exists does this to every server it touches. The same manual says the file should only be atomically replaced, never modified in place, so ship it as a temporary file and a rename:

$ scp revoked.krl [email protected]:/tmp/revoked.krl
$ ssh [email protected] 'sudo install -m 644 /tmp/revoked.krl /etc/ssh/revoked_keys.new && sudo mv /etc/ssh/revoked_keys.new /etc/ssh/revoked_keys'

Create an empty KRL with ssh-keygen -k -f revoked.krl and put it on every server before the RevokedKeys line goes in.

Host certificates end the trust-on-first-use prompt

The other half is the server proving itself. One line in each person's known_hosts replaces a fingerprint per server:

@cert-authority srv* ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFzEVeeEYb15GP0WHQEkC6jCsUtbWw+ty4bB0AF/fCI9 host-ca

Before we re-signed the host certificates with the short names, the client connecting as srv2 answered Certificate invalid: name is not a listed principal. Sign every name people type into the host certificate (ssh-keygen -h -n srv1,srv1.example.co.ke,192.0.2.11), and if people connect by address, put the addresses in the @cert-authority pattern too. After we rebuilt one server's host key, a plain known_hosts threw REMOTE HOST IDENTIFICATION HAS CHANGED, which teaches people to delete the line and accept whatever answers. With the CA line, the fix is a signature on the new key, and nobody's known_hosts changes.

When authorized_keys still wins

Three servers and four people who rarely change: keep authorized_keys, put the files in config management, and remove a leaver's line everywhere in one run. A CA adds a signing key you now have to protect, a KRL that can lock you out, and a habit of reissuing certificates. It earns that cost when people join, leave or rotate every month, when contractors need access for a week, or when you cannot say today which servers hold a given person's key.

On the servers CloudSpinx builds and runs for organizations in Kenya, SSH access sits in the hardening baseline beside the items in our Linux server setup checklist and the fail2ban and PerSourcePenalties choice. If a former contractor's key may still sit on your servers, run sudo sh -c 'cat /root/.ssh/authorized_keys* /home/*/.ssh/authorized_keys*' | ssh-keygen -lf - on each and send the fingerprints with a count of who should have access, on WhatsApp at +254 713 403 044 or through the Linux scoping form under "Hardening and an audit". You get back which keys to remove, whether a CA is worth it for your team size, and the drop-in, principals files and KRL push for your servers. If we then run them, it is one monthly figure.

WhatsApp