SSH Hardening in 2026: Keys, Certificates, and Bastion Patterns
We had 140 engineers with 300 static public keys scattered across authorized_keys files nobody could audit. Moving to SSH certificates with short TTLs made access reviewable again.
Key takeaways
- Harden SSH by disabling password and keyboard-interactive login, using ed25519 keys, and replacing per-host authorized_keys with short-lived certificates signed by one user CA.
- Hosts trust the CA through TrustedUserCAKeys, certificates expire in hours, and a revocation list handles emergencies.
- Keep a bastion with ProxyJump so internal hosts expose no public SSH.
On this page
Harden SSH in three layers: turn off password and keyboard-interactive auth and use ed25519 keys; replace scattered authorized_keys files with short-lived certificates signed by one CA that every host trusts via TrustedUserCAKeys; and reach internal hosts only through a bastion with ProxyJump. Certificates make access auditable and offboarding automatic.
Verified against
OpenSSH 10.6 (released 2026-10-06), against the openssh.org release notes and the OpenBSD ssh-keygen(1) and sshd_config(5) man pages. Checked October 2026.
An auditor asked a fair question: "Which engineers can SSH into the payments database host, and how would you revoke someone who left last week?" The honest answer was that I'd have to grep authorized_keys files across 60 hosts, match public keys to people by memory, and hope nobody had copied a key onto a box we'd forgotten. That's not an access control system. That's a liability with a shell prompt.
The fix isn't more careful key management. It's getting out of the static-key business entirely and issuing short-lived SSH certificates instead.
Kill password auth and weak keys first
Before anything clever, the baseline. In /etc/ssh/sshd_config on every host:
# /etc/ssh/sshd_config
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
PubkeyAuthentication yes
AuthenticationMethods publickey
KbdInteractiveAuthentication defaults to yes and PermitRootLogin defaults to prohibit-password, so both lines are doing real work. Validate before you reload, because a typo here locks you out:
sudo sshd -t && sudo systemctl reload ssh
(The unit is sshd on RHEL-family systems.) And use ed25519, not RSA. It's shorter, faster, and there's no reason to generate a 4096-bit RSA key in 2026:
ssh-keygen -t ed25519 -C "kiril@devopsness" -f ~/.ssh/id_ed25519
Current OpenSSH already helps on the transport side: since 10.0 the default key exchange is the post-quantum hybrid mlkem768x25519-sha256, DSA support is gone, and since 10.1 the client warns when a connection negotiates a non-post-quantum key exchange. Keep hosts on a current release and you get those for free.
That's table stakes. It does nothing about the audit problem, because you're still distributing public keys to hosts and hoping the set stays clean.
Certificates replace authorized_keys
The shift is this: instead of each host trusting a list of individual public keys, every host trusts one certificate authority. When an engineer authenticates, they don't present a raw key. They present a certificate, signed by the CA, that says who they are, which principals (roles) they hold, and when it expires. Usually 8 hours from now.
You set up a CA key once, kept offline or in a signing service:
ssh-keygen -t ed25519 -f ssh_ca -C "devopsness-ssh-ca"
Every host gets configured to trust it, and the per-host trust config is a couple of lines:
# /etc/ssh/sshd_config
TrustedUserCAKeys /etc/ssh/ssh_ca.pub
AuthorizedPrincipalsFile /etc/ssh/auth_principals/%u
No more per-user keys on hosts. To grant someone access, the CA signs them a cert. To revoke access, you stop signing. Since certs expire in 8 hours, the engineer who left last week already lost access automatically, the moment their last cert expired.
Signing a cert with real constraints
The cert carries the authorization inside it. This is the CA signing a user's key with a principal, an expiry, and forced restrictions:
ssh-keygen -s ssh_ca \
-I "kiril@devopsness" \
-n "db-readonly,web" \
-V +8h \
-z 1042 \
-O clear -O permit-pty \
-O source-address=10.20.0.0/16 \
~/.ssh/id_ed25519.pub
The -n db-readonly,web sets the principals this cert is valid for. On the host side, the AuthorizedPrincipalsFile for the login user lists which principals may log in, so a cert with only web can't touch a database host that requires db-readonly. Without a principals file, sshd requires the login username itself to be one of the cert's principals, and it rejects certificates with no principals at all. The -V +8h is the expiry and -z sets a serial you can revoke later. The -O clear drops all default permissions, then we add back only permit-pty, so no port forwarding or agent forwarding unless explicitly granted. The source-address pins the cert to our VPN range.
In practice you don't run ssh-keygen -s by hand. Front the CA with a service (HashiCorp Vault's SSH secrets engine, or Smallstep) that authenticates the engineer against your IdP, checks group membership, and mints the cert. The human never touches the CA private key.
The bastion still earns its place
Certificates handle identity. The bastion handles network position. Our database and internal hosts have no public SSH port at all; the only inbound SSH comes from one hardened bastion in a public subnet. Engineers use a jump config so it's transparent:
# ~/.ssh/config
Host db-*.internal
ProxyJump bastion.devopsness.net
User deploy
Host bastion.devopsness.net
HostbasedAuthentication no
IdentityFile ~/.ssh/id_ed25519
ProxyJump (the -J flag) tunnels an end-to-end SSH session through the bastion, so you never need agent forwarding, the old pattern that exposes your agent socket to anyone with root on the bastion. The bastion logs every session, and because everyone connects with a certificate carrying their identity, the logs actually name people instead of showing an anonymous deploy user. If you're newer to client-side config like this, our SSH tutorial on keys and config covers the basics.
Answering the auditor
The second half of the auditor's question was revocation. Beyond expiry, keep a Key Revocation List for the panic case, when you need someone gone in the next 8 minutes, not the next 8 hours:
# /etc/ssh/sshd_config
RevokedKeys /etc/ssh/revoked_keys
Revoke by serial with ssh-keygen -k, adding to the existing list with -u, then ship the file to every host:
echo "serial: 1042" > revoke.txt
ssh-keygen -k -u -f /etc/ssh/revoked_keys -s ssh_ca.pub revoke.txt
The cert is dead on next connection, no waiting for TTL. One sharp edge: if RevokedKeys points at a file sshd cannot read, public key authentication is refused for every user, so deploy the file with the same care as the config.
Questions people ask
Are SSH certificates better than authorized_keys?
For teams beyond a handful of engineers, yes. With authorized_keys, every host holds its own list of trusted keys, so auditing and revoking means touching every host. With certificates, hosts trust one CA, each certificate names its owner, principals and expiry, and access lapses automatically when it expires. The cost is running a CA and a signing service, which is why tiny setups often skip it.
How long should an SSH certificate be valid?
Match it to a working day: 8 to 12 hours is a common default, so engineers sign in once each morning through the IdP and the certificate is useless by evening. Automation and CI can use minutes. Long validity, such as weeks, recreates the static-key problem, because revocation then depends entirely on the KRL being current on every host.
The call we'd make
If you have more than a dozen engineers and more than a handful of hosts, move to SSH certificates. The authorized_keys model does not scale to a number you can audit, and "grep and hope" is not a revocation story you want to give a security reviewer. The setup cost is real, you're running a CA and a signing service, but 8-hour certs turn offboarding from a manual key hunt into a non-event. Keep the bastion regardless. Certificates prove who you are; the bastion controls where you can reach, and you want both.
Sources
Cite this article
Kiril Urbonas (2026). SSH Hardening in 2026: Keys, Certificates, and Bastion Patterns. DevOpsNess. Updated 2026-11-15. https://www.devopsness.com/blog/ssh-hardening-2026-keys-certificates-bastion
[SSH Hardening in 2026: Keys, Certificates, and Bastion Patterns](https://www.devopsness.com/blog/ssh-hardening-2026-keys-certificates-bastion) (Kiril Urbonas, DevOpsNess, updated 2026-11-15)
More from Linux
Explore more articles in this category
DNS Troubleshooting on Linux: A Systematic Approach
\"It's always DNS\" is a joke because the failure modes are so scattered: resolver config, caching, search domains, split DNS. Here is where to actually look.
eBPF Tools for Everyday Ops: bpftrace Patterns We Use
bpftrace one-liners replace strace, perf top, and a half-dozen ad-hoc debugging scripts. The patterns that actually earn their place when you're troubleshooting at 2 AM.
Operational Checklist: Systemd Service Reliability Patterns
A condensed checklist of the systemd unit-file patterns we now use everywhere, with the production reasons each one matters.
You might have missed
Evergreen posts worth revisiting.