Since version 5.4, released in 2010, OpenSSH has shipped a certificate system that lets you replace lists of public keys in authorized_keys with your own certificate authority (CA). Servers trust the CA’s public key and accept any user key it has signed, together with an identity, a list of allowed accounts, an expiry date and, optionally, usage restrictions. It all works with the standard ssh, sshd and ssh-keygen tools, with no extra software.
The key points of SSH certificates in 20 seconds
- An SSH CA signs public keys into certificates with identity and expiry.
- Servers only need the CA’s public key.
- Host certificates remove the first-connection trust prompt.
- OpenSSH 10.3 changed how empty and wildcard principals behave.
The problem they solve is familiar to anyone who has inherited servers: an authorized_keys file with dozens of lines, comments that say nothing and keys from laptops nobody can account for. A public key has no verifiable owner and no expiry, and removing it means visiting every machine. With certificates, access is granted by signing and withdrawn by no longer signing.
How certificates differ from plain keys
OpenSSH certificates are not X.509 like HTTPS certificates. They use their own format, documented in the project’s PROTOCOL.certkeys file, which wraps the public key with an identifier, a serial number, a list of principals (the user or host names it is valid for), a validity period, critical options and extensions, all signed by the CA.
| Keys in authorized_keys | SSH certificates | |
|---|---|---|
| What servers receive | Every key of every user | A single CA public key |
| Expiry | None | Mandatory, from minutes to years |
| Identity | A free-text comment | Signed ID and serial number, written to the logs |
| Restrictions | Per-line options on each server | Inside the certificate itself |
| Offboarding | Delete the key on every machine | Stop signing and, if needed, revoke with a KRL |
| Server identity | Trust on first use | Verifiable host certificate |
Use two separate CAs, one for users and one for hosts, as the OpenSSH documentation recommends. If one is compromised, the other remains trustworthy.
User certificates step by step
1. Create the user CA. It is an ordinary key pair. Keep the private key off your servers, ideally on an isolated machine or a hardware security module:
ssh-keygen -t ed25519 -f user_ca -C "User CA"Code language: JavaScript (javascript)
2. Make the server trust it. Copy user_ca.pub to the server and add the TrustedUserCAKeys directive. On distributions that include the sshd_config.d directory, such as Debian, Ubuntu or RHEL 9 and later, a separate file is cleaner:
sudo install -m 644 user_ca.pub /etc/ssh/user_ca.pub
echo "TrustedUserCAKeys /etc/ssh/user_ca.pub" | sudo tee /etc/ssh/sshd_config.d/10-ca.conf
sudo sshd -t
sudo systemctl reload sshCode language: PHP (php)
On Debian and Ubuntu the service is called ssh; on RHEL, Rocky, AlmaLinux or Fedora it is sshd. sshd -t validates the configuration before reloading, and keeping an existing session open while you test avoids locking yourself out.
3. Sign the user’s key. The user generates a key pair as usual and hands over the public key. The CA administrator signs it:
ssh-keygen -s user_ca -I "alice@company" -n alice -V -5m:+8h -z 1001 id_ed25519.pubCode language: CSS (css)
- -s user_ca: the CA private key used for signing.
- -I: the certificate ID. It is written to the server’s authentication log on every login, so make it identify the person.
- -n: principals, the accounts the certificate is valid for. Never leave it out.
- -V -5m:+8h: valid from five minutes ago (to absorb clock skew) until eight hours from now.
- -z 1001: a serial number, handy for revoking a specific certificate later.
The result is id_ed25519-cert.pub, which the user keeps next to the private key. The ssh client picks it up automatically when connecting with that key. To inspect a certificate’s principals, validity, serial and extensions:
ssh-keygen -L -f ~/.ssh/id_ed25519-cert.pubCode language: JavaScript (javascript)
Principals: separating identity from accounts
By default, the server requires the account name you log in as to appear among the certificate’s principals. That forces the CA to know every machine’s accounts and gets awkward with shared accounts such as deploy or ubuntu. AuthorizedPrincipalsFile flips the model: the certificate carries the identity of a person or group, and each server decides which identities may use each local account.
# /etc/ssh/sshd_config.d/10-ca.conf
TrustedUserCAKeys /etc/ssh/user_ca.pub
AuthorizedPrincipalsFile /etc/ssh/principals/%u
# /etc/ssh/principals/deploy
alice
web-team
ci-runnerCode language: PHP (php)
With this setup, a certificate with the principal web-team can log in as deploy on any server that lists it, without the CA knowing anything about that account. If an account has no principals file, nobody gets in with a certificate. For more dynamic setups, AuthorizedPrincipalsCommand queries an external program, for example an LDAP directory.
One recent change matters here. According to the release notes for OpenSSH 10.3, released on 2 April 2026, a certificate with an empty principals section used to match any principal when the CA was configured in authorized_keys with the principals option; it now matches none. CAs set with TrustedUserCAKeys were never affected. The same release dropped wildcard support in user certificate principals, keeping it only for host certificates. Review any workflow that relies on either behaviour before upgrading.
Host certificates: no more first-connection prompt
The first time you connect to a server, ssh asks whether to trust its fingerprint. Hardly anyone checks it, and accepting blindly invites a man-in-the-middle attack. With a host CA, clients trust one key and verify every server it has signed:
ssh-keygen -t ed25519 -f host_ca -C "Host CA"
ssh-keygen -s host_ca -I "web01" -h -n web01.example.com,web01 -V +52w /etc/ssh/ssh_host_ed25519_key.pubCode language: JavaScript (javascript)
-h marks it as a host certificate, and -n lists the names clients use to connect. On the server, add the HostCertificate line and reload the service:
HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
On clients, one line in known_hosts (or /etc/ssh/ssh_known_hosts for the whole machine) covers an entire domain, because host certificates do accept wildcards:
@cert-authority *.example.com ssh-ed25519 AAAA...contents of host_ca.pub...Code language: CSS (css)
If the server’s certificate has expired, does not match the hostname or was signed by another CA, ssh will not accept it. Plan host certificate renewal before expiry, because an expired certificate sends users back to manual verification or breaks automated connections.
Restricting and revoking
A certificate can limit what it may be used for, which is especially useful for automation: if the key leaks, the damage is contained. This example signs a deployment key that can only run one script, only from the internal network and only for 15 minutes:
ssh-keygen -s user_ca -I "ci-deploy" -n deploy -V +15m -O clear -O force-command=/usr/local/bin/deploy.sh -O source-address=10.0.0.0/8 ci_key.pubCode language: JavaScript (javascript)
clear removes the extensions granted by default (interactive terminal, port, agent and X11 forwarding, and running ~/.ssh/rc). force-command and source-address are critical options: a server that does not understand them rejects the certificate instead of ignoring them. For FIDO keys there is also verify-required, which demands user verification by PIN or biometrics.
The best revocation is a short lifetime: an eight-hour certificate simply stops working. For longer-lived certificates, OpenSSH offers compact binary key revocation lists (KRLs). With the CA’s public key you can revoke by serial number or by ID using a specification file:
# revoke.txt
serial: 1001
id: intern-2025
ssh-keygen -k -f /etc/ssh/revoked_keys -s user_ca.pub revoke.txt
ssh-keygen -Q -f /etc/ssh/revoked_keys id_ed25519-cert.pubCode language: PHP (php)
The second command checks whether a given certificate is revoked; add -u to update an existing KRL. Enable it on the server with RevokedKeys /etc/ssh/revoked_keys and distribute the file to every machine that trusts the CA. One detail from the sshd_config manual: if that file cannot be read, sshd refuses public key authentication for all users.
In production: protect the CA and stop signing by hand
The CA private key becomes the most sensitive piece of your infrastructure: whoever holds it can log in to every server that trusts it. ssh-keygen can sign with a key stored on a PKCS#11 token (-D) or held in ssh-agent (-U), so it never sits in a file.
Signing by hand is fine for learning or for small estates. Beyond that, a service that authenticates users against the company identity provider (SSO, MFA or OIDC) and issues short-lived certificates automatically makes more sense. The best-known options are HashiCorp Vault’s SSH secrets engine, Smallstep’s open-source step-ca with OIDC login, and Teleport, which adds role-based access control and session recording. With any of them, offboarding comes down to disabling the user in the identity provider.
Check OpenSSH versions with ssh -V on clients and servers first. Enterprise distributions usually trail the upstream branch, which reached 10.6 in October 2026, and some of the changes above may be missing from, or backported into, each system’s packages.
Frequently asked questions
Do SSH certificates replace keys?
No. Users still have a key pair; the certificate is their public key signed by the CA, with an identity, allowed accounts and an expiry.
Do I need extra software for SSH certificates?
No. ssh, sshd and ssh-keygen have supported them since OpenSSH 5.4. External tools are only needed to automate issuance.
How do I revoke an SSH certificate?
Issue short-lived certificates where possible. To revoke early, build a KRL with ssh-keygen -k and enable it with RevokedKeys in sshd.
Can one CA sign both users and hosts?
It can, but the OpenSSH documentation recommends separate CAs so that compromising one does not affect the other.
Sources:
