To configure SSH certificates on Ubuntu 24.04 VPS: Generate an Ed25519 Certificate Authority key pair with ssh-keygen -t ed25519, deploy the CA public key to /etc/ssh/ca/user_ca.pub, configure TrustedUserCAKeys and AuthorizedPrincipalsFile inside /etc/ssh/sshd_config.d/10-ssh-ca.conf, run sudo sshd -t, reload ssh, and sign time-bounded user certs via ssh-keygen -s.[1][2]
Follow this production security runbook to replace static authorized_keys sprawl across cloud instances, eliminate manual key offboarding delays, and account for Ubuntu 24.04 LTS’s default ssh.socket activation behavior.[3]
Why Configuring SSH Certificates on Ubuntu VPS Replaces Static authorized_keys
Managing fleets of Linux servers with raw ~/.ssh/authorized_keys files introduces two severe operational flaws: every new engineer key must be pushed to every server, and departing staff retain persistent shell access until their public key line is deleted from every host.
Deploying an OpenSSH Certificate Authority (CA) inverts this trust model. Each Ubuntu VPS trusts one compact CA public key (TrustedUserCAKeys), while engineers authenticate with short-lived, cryptographically signed certificates (-cert.pub) that automatically expire after hours or days.[1][2]
What is the difference between OpenSSH SSH Certificates and X.509 SSL Certificates?
According to the OpenSSH ssh-keygen(1) manual, OpenSSH certificates are not X.509 SSL/TLS certificates.[2] They omit complex ASN.1 hierarchies and external root CA chains, packing only a public key, identity string (-I), authorized principal names (-n), validity window (-V), and optional critical permissions directly into a lightweight signed Ed25519 structure.[2]
Authentication Matrix: Static Public Keys vs. OpenSSH CA Certificates
| Operational Factor | Static Keys (authorized_keys) |
OpenSSH CA Certificates (TrustedUserCAKeys) |
Password Authentication |
|---|---|---|---|
| Per-Server Key Distribution | Required on every VPS per user | One CA public key deployed once per fleet[1] | High credential reuse risk |
Built-In Expiration (TTL) |
None (valid indefinitely until deleted) | Enforced cryptographically (-V +8h, +1w)[2] |
Manual rotation required |
| Audit Attribution | Generic fingerprint logged | Logs exact key ID (-I) & serial number (-z) |
Username only |
| TOFU Host Warnings | Frequent "authenticity of host cannot be established" |
Eliminated completely with Host Certificates | Severe MITM exposure |
| Immediate Revocation | Manual edit across all servers | Centralized Key Revocation List (RevokedKeys)[1] |
Account lock required |
Step-by-Step Runbook: Configuring SSH Certificates on Ubuntu 24.04 VPS
Separate the Certificate Authority (CA) signing host (a hardened offline admin workstation, bastion, or HSM) from the Ubuntu 24.04 target VPS. Never store the CA private signing key on production web or database servers.
Step 1: Generate the User CA Key Pair (Offline Admin Workstation)
Create a dedicated Ed25519 CA key pair on your secure administrative host with a strong passphrase:[2]
# Run on your secure local CA workstation (NOT on the target VPS)
mkdir -p ~/.ssh/ca
ssh-keygen -t ed25519 -f ~/.ssh/ca/prod_user_ca -C "NextGen Production SSH User CA"
This creates prod_user_ca (private signing key kept strictly offline) and prod_user_ca.pub (public key distributed to Ubuntu servers).
Step 2: How do TrustedUserCAKeys and AuthorizedPrincipalsFile work together in sshd_config?
On the Ubuntu 24.04 VPS, TrustedUserCAKeys defines which CA public keys may sign valid user certificates, while AuthorizedPrincipalsFile enforces role-based mapping.[1] OpenSSH evaluates AuthorizedPrincipalsFile using tokens such as %%, %h, %U, and %u (target username); if specified, the offered certificate must carry at least one matching principal listed inside that user’s principals file.[1]
Copy prod_user_ca.pub to /etc/ssh/ca/user_ca.pub on the Ubuntu 24.04 VPS and configure permissions:
sudo mkdir -p /etc/ssh/ca /etc/ssh/auth_principals
# Paste contents of ~/.ssh/ca/prod_user_ca.pub into /etc/ssh/ca/user_ca.pub
sudo nano /etc/ssh/ca/user_ca.pub
sudo chmod 644 /etc/ssh/ca/user_ca.pub
Create an OpenSSH drop-in configuration inside /etc/ssh/sshd_config.d/:[1][3]
sudo tee /etc/ssh/sshd_config.d/10-ssh-ca.conf > /dev/null <<'EOF'
# Trust user certificates signed by our internal CA
TrustedUserCAKeys /etc/ssh/ca/user_ca.pub
# Map allowed role principals dynamically per system account (%u)
AuthorizedPrincipalsFile /etc/ssh/auth_principals/%u
# Enforce certificate/public-key authentication only
PubkeyAuthentication yes
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin prohibit-password
EOF
Define which certificate principals are permitted to open shells as the target system account (for example, ubuntu or deploy):
sudo tee /etc/ssh/auth_principals/ubuntu > /dev/null <<'EOF'
prod-sre
deploy-automation
ubuntu
EOF
sudo chmod 644 /etc/ssh/auth_principals/ubuntu
Step 3: Validate Configuration and Reload Ubuntu 24.04 OpenSSH
Always run syntax validation before applying changes so an active administrative shell is never locked out:[3]
sudo sshd -t && sudo systemctl reload ssh
Step 4: Sign and Inspect an Ephemeral User Certificate
Back on your offline CA workstation, sign a team member’s standard public key (~/.ssh/id_ed25519.pub) with a 12-hour shift validity window and unique serial number:[2]
ssh-keygen -s ~/.ssh/ca/prod_user_ca \
-I "[email protected]" \
-n prod-sre \
-V +12h \
-z 101 \
~/.ssh/id_ed25519.pub
Inspect the resulting id_ed25519-cert.pub payload to confirm exact principals, serial ID, and expiry timestamps before distributing it to the user:
ssh-keygen -L -f ~/.ssh/id_ed25519-cert.pub
When the engineer runs ssh -i ~/.ssh/id_ed25519 [email protected], OpenSSH automatically presents id_ed25519-cert.pub alongside the private key without requiring any personal entry in ~/.ssh/authorized_keys.
Ubuntu 24.04 Systemd ssh.socket, RevokedKeys (KRL), and Host Certificates
Why does systemctl restart ssh fail to apply port changes on Ubuntu 24.04?
Starting in Ubuntu 24.04 LTS, OpenSSH defaults to systemd socket activation (ssh.socket) rather than keeping sshd running continuously in memory. While auth-level changes (TrustedUserCAKeys) apply cleanly on systemctl reload ssh, network-socket directives such as changing Port 22 require reloading the systemd generator unit and restarting ssh.socket:
sudo sshd -t
sudo systemctl daemon-reload
sudo systemctl restart ssh.socket
How do you revoke an active SSH certificate before its expiration timestamp?
Even with short validity timers (-V +12h), a compromised laptop requires instant revocation before the TTL expires. OpenSSH supports Key Revocation Lists (KRL) via the RevokedKeys directive in sshd_config.[1]
- Generate a KRL binary revoking serial number
101signed byprod_user_ca.pubon your CA workstation:[2]
# Create or update KRL revoking serial 101
ssh-keygen -k -f /tmp/revoked_keys.krl -s ~/.ssh/ca/prod_user_ca.pub -z 101
- Deploy
/etc/ssh/revoked_keys.krlwith readable permissions (0644) to the Ubuntu 24.04 VPS and appendRevokedKeys /etc/ssh/revoked_keys.krlto/etc/ssh/sshd_config.d/10-ssh-ca.conf.
Critical Pitfall with RevokedKeys File Permissions: According to the OpenSSH sshd_config(5) specification, if the file specified by RevokedKeys is missing or unreadable by sshd, public key and certificate authentication is immediately refused for all users across the server.[1] Always verify chmod 644 /etc/ssh/revoked_keys.krl and keep an active emergency session open before reloading ssh.
Eliminate Client Host Warnings with Host Certificates: Beyond user auth, generate a dedicated Host CA key (ssh_host_ca), sign each VPS host key (ssh-keygen -s ssh_host_ca -I vps01 -h -n vps01.example.com,203.0.113.50 -V +52w /etc/ssh/ssh_host_ed25519_key.pub), configure HostCertificate in sshd_config.d, and distribute @cert-authority *.example.com ... inside team ~/.ssh/known_hosts files so server rebuilds never break SSH fingerprint checks.
Zero-Downtime Verification and Audit Checklist
Organizations scaling engineering access across production cloud clusters, CI/CD runners, and database nodes require predictable network throughput alongside strict SSH governance. Deploy security-hardened infrastructure on bare-metal NextGen Dedicated Servers or low-latency Dedicated Servers in Pakistan.
- Keep a secondary root or sudo SSH session open in a separate terminal window until certificate login succeeds.
- Verify certificate authentication explicitly inside verbose client output:
ssh -v -i ~/.ssh/id_ed25519 ubuntu@<VPS-IP>(confirmServer accepts key: [email protected]). - Inspect server-side journal logs for audited identity tags (
-I):sudo journalctl -u ssh -n 20 --no-pager. - Confirm fallback passwords remain locked (
sudo sshd -T | grep -E "passwordauthentication|trustedusercakeys").
Deploy Hardened Cloud & Bare-Metal Linux Infrastructure
Run mission-critical applications on enterprise NVMe dedicated servers with isolated root access, DDoS protection, and sub-millisecond domestic routing.
Explore Dedicated ServersDisclaimer: This post is for informational and educational purposes only, accurate to the best of our knowledge at publication. It does not constitute security auditing advice. Always keep an active out-of-band console or secondary SSH session open when testing sshd_config changes.
Sources & Official References
- OpenBSD / OpenSSH Project. "sshd_config(5) — OpenSSH daemon configuration file (TrustedUserCAKeys, AuthorizedPrincipalsFile, RevokedKeys)." OpenBSD Manual Pages. Available at: https://man.openbsd.org/sshd_config
- OpenBSD / OpenSSH Project. "ssh-keygen(1) — OpenSSH authentication key utility (CERTIFICATES & KEY REVOCATION LISTS)." OpenBSD Manual Pages. Available at: https://man.openbsd.org/ssh-keygen
- Canonical Ltd. "OpenSSH Server Configuration and Hardening." Ubuntu Server Documentation. Available at: https://ubuntu.com/server/docs/openssh-server
