
The Live Session Revocation Gap: Why OpenSSH KRL and AuthorizedKeys Fall Short in Real-Time Offboarding
secure-access
This series is part of WarnHack's Topical Authority research.
14 Articles
The Live Session Revocation Gap: Why OpenSSH KRL and AuthorizedKeys Fall Short in Real-Time Offboarding
Every few months, an offboarding ticket comes through marked critical: an engineer left under contentious circumstances, or an alert fired indicating a private key leaked into a public repo. The on-call runbook almost always prescribes the same sequence: remove the public key from the identity provider, wipe the line from ~/.ssh/authorized_keys across the fleet (or push an updated SSH key revocation list), run systemctl reload sshd, and close the ticket.
Then we check who or ss -tnp on the target box twenty minutes later, and the user is still sitting there editing files in vim, tunneling traffic through a dynamic SOCKS proxy, or opening fresh channels over an established ControlMaster socket.
OpenSSH does exactly what it was designed to do, which is why this keeps catching teams off guard. Authentication happens once, upfront. Once that handshake completes, the cryptographic material that got the user into the box is irrelevant to the running kernel process handling their traffic.
Understanding the SSH Key Revocation List (KRL)
What Is an SSH Key Revocation List?
An SSH key revocation list is a compact binary file format introduced in OpenSSH 6.4 to replace flat, line-delimited blacklist files. It tracks revoked raw public keys, key fingerprints, and OpenSSH CA certificate serial numbers or Key IDs.
Because it uses bitmap and bloom-filter-like structures for serial ranges, a KRL with thousands of serials takes up mere kilobytes on disk, making lookup overhead negligible during authentication handshakes.
How KRL Works with OpenSSH Certificate Authorities
When running an OpenSSH CA, you sign user keys with a CA key, injecting principals, valid-before/after timestamps, and serial numbers directly into the cert. The host's sshd only needs the CA's public key (via TrustedUserCAKeys) to validate signatures.
The problem arises when an 8-hour or 24-hour cert is issued and must be revoked thirty minutes into its lifetime. You cannot pull the signed cert back from the engineer's laptop. Instead, the CA operator generates an updated KRL containing the revoked certificate's serial number or key ID and ships that binary to every host.
KRL vs. CRL: Key Differences in SSH and TLS Revocation
In X.509/TLS worlds, Certificate Revocation Lists (CRLs) and OCSP endpoints are either checked online by clients or stapled by servers. SSH explicitly rejects this model. There is no automated network protocol inside OpenSSH to query an online revocation service or fetch an updated KRL from an endpoint during connection time.
OpenSSH revocation is strictly local and static. If your configuration management daemon hasn't written the updated KRL file to /etc/ssh/revoked_keys on a specific node, that node knows nothing about the revocation.
Why Managing SSH Key Revocation Is Critical for Security
The Dangers of Stale and Compromised SSH Keys
Raw public keys dumped into static ~/.ssh/authorized_keys files are notorious for accumulating like sediment. Engineers copy their personal laptop keys to utility boxes for quick debugging, forget about them, and change jobs two years later. If an offboarding workflow merely disables their single sign-on account without scrubbing host-level key files or invalidating running connections, access persists.
Meeting Regulatory Compliance and Access Control Standards
Auditors are increasingly testing real-time deprovisioning rather than just checking if an account shows "Suspended" in Okta or Google Workspace. Under directives like the CERT-In Cyber Security Directions (No. 20(3)/2022-CERT-In), organizations are expected to maintain strict access control logs and demonstrate rapid containment during an unauthorized access incident.
Relying on key deletion while an engineer maintains a persistent terminal violates containment mandates during an incident review. If the session remains open past the revocation window, the access was never actually severed.
Eliminating the Administrative Burden of Manual Deprovisioning
Editing raw authorized_keys across a dynamic fleet of thousands of nodes via ad-hoc Ansible or Salt runs is brittle. Network partitions cause plays to fail, leaving stale keys on straggler nodes. A centralized KRL or CA architecture helps phase out static authorized_keys and solves the persistence problem for future connections, but teams mistake it for a live-kill mechanism.
How to Revoke SSH Keys: Standard Methods Explained
Method 1: Removing Public Keys from authorized_keys
The legacy baseline: mutate the target user's ~/.ssh/authorized_keys file by stripping out the compromised entry. This prevents subsequent handshakes using that private key. It does not touch any existing fork of sshd.
Method 2: Centralized Revocation Using an SSH Key Revocation List
You declare a single path in the system-wide daemon configuration:
# /etc/ssh/sshd_config
RevokedKeys /etc/ssh/revoked_keys ClientAliveInterval 60 ClientAliveCountMax 3
# Note: Even with strict ClientAlive settings, established sessions remain # valid until explicitly killed at the OS process or session level.
This tells sshd to reject any connection where the presented public key or cert matches an entry in that binary file. It centralizes control away from user home directories into an root-owned file.
When to Use KRL vs. authorized_keys Removal
| Requirement | authorized_keys Removal | SSH Key Revocation List (KRL) |
|---|---|---|
| Target Format | Raw SSH Public Keys | Public Keys, Cert Serials, Key IDs |
| File Permissions | User-owned (usually) | Root-owned |
| CA Compatibility | Cannot revoke cert serials | Native cert serial support |
| Session Impact | Zero impact on live sessions | Zero impact on live sessions |
Step-by-Step Guide: Implementing an SSH Key Revocation List
Prerequisites: Setting Up an OpenSSH CA
Assuming you already have a CA keypair generated at /etc/ssh/ca_user_key, you sign keys using standard serial numbers:
# Sign a developer's key with serial 101
ssh-keygen -s /etc/ssh/ca_user_key -I dev-alice -n alice,ubuntu -z 101 -V +1d id_ed25519.pub
Creating a New Key Revocation List with ssh-keygen
To initialize a new KRL or revoke a plain public key, pass -k to ssh-keygen:
# Initialize a new KRL with an initial bad key
ssh-keygen -k -f /etc/ssh/revoked_keys -z 1 ~/.ssh/id_ed25519.pub
If you need to revoke by CA certificate serial number rather than a raw key file, construct a flat text file specifying the serials, like serial: 101, and pass that to the command.
Adding Revoked Keys or Key IDs to an Existing KRL
To update the list later, run the command with -u (update):
# Append another bad key to the binary KRL
ssh-keygen -k -u -f /etc/ssh/revoked_keys compromised_key.pub
Verifying and Testing That Revoked SSH Keys Are Denied
You can query the binary KRL locally using -Q without running an active SSH connection:
# Check if a public key is contained in the KRL
ssh-keygen -Q -f /etc/ssh/revoked_keys ~/.ssh/id_ed25519.pub
If the key is present, it prints output confirming the match:
/root/.ssh/id_ed25519.pub: REVOKED
# Exit status will be 0 if revoked, 1 if not.
Now reload the listener:
systemctl reload sshd
The Flaw: Why Reloading sshd Does Nothing to Active Attackers
Here is what happens in practice during a real revocation event.
An operator adds a key to the KRL, verifies it with ssh-keygen -Q, runs systemctl reload sshd, and assumes the daemon drops disconnected or blacklisted users. The operator tests logging in again with the revoked key from another terminal:
$ ssh -i ~/.ssh/id_ed25519 alice@target-node
alice@target-node: Permission denied (publickey).
Everything looks closed. But back in the original session that was opened prior to the reload:
# Still in the established terminal
alice@target-node:~$ whoami alice alice@target-node:~$ hostname target-node alice@target-node:~$ uptime 16:42:11 up 12 days, 3:11, 2 users, load average: 0.04, 0.01, 0.00
OpenSSH only checks authorized_keys and the RevokedKeys file during pre-authentication. By design within the OpenSSH privilege separation model, once the client passes authentication, the main listening sshd process forks an unprivileged worker child to manage the session and drops privileges.
When you execute systemctl reload sshd, the system sends a SIGHUP to the parent listener PID. The parent re-reads /etc/ssh/sshd_config and re-opens its network sockets. It deliberately ignores its active child processes so that routine configuration updates or service reloads do not sever active administrator connections across the fleet.
The ControlMaster Problem
It gets worse if the client has SSH connection multiplexing enabled in their local ~/.ssh/config:
Host *
ControlMaster auto ControlPath ~/.ssh/control-%r@%h:%p ControlPersist 10m
With an active master socket, running ssh alice@target-node from the client machine does not initiate a new TCP handshake with the target's port 22. It writes to the local UNIX domain socket created by the master process.
The master process requests a new channel over the existing encrypted transport layer. The server's child sshd worker simply allocates a new pseudoterminal. No authentication occurs. The KRL is never re-read. The revoked user can spawn fresh shell sessions indefinitely as long as the master connection stays alive.
Executing Real Real-Time Offboarding
Revoking the credential is step one. Step two must be terminating the OS-level primitives associated with the identity.
1. Kill the User Processes and Sessions
If the system runs systemd-logind, dropping their session requires targeting their logind scope directly:
# Terminate all scopes, slices, and processes for the target user
loginctl terminate-user alice
If logind is not available, or you need to ensure the network socket is blown away immediately, kill the pseudo-terminals and user processes manually:
# Forcibly sever any hanging pts allocation
pkill -9 -u alice -t pts/*
# Kill remaining user-owned processes pkill -9 -u alice
2. The Detached Session Trap (tmux and screen)
Even running pkill -9 -u <username> -t pts/ will miss detached terminal multiplexers if you aren't careful. A tmux server detached from any PTS does not have a controlling terminal matching pts/. It runs as an independent daemon owned by the user.
By default on some Linux distributions, user processes stay alive after logout unless configured otherwise. Check /etc/systemd/logind.conf:
[Login]
KillUserProcesses=yes
If this is set to no, a malicious user who anticipates revocation can simply run tmux or nohup backchannel.sh &, let their SSH connection drop or be killed, and retain background execution on the server.
Best Practices for Maintaining SSH Key Revocation Lists
Automating KRL Distribution Across Your Infrastructure
If you rely on KRLs, distribution latency is your maximum window of vulnerability for new sessions. Distributing a binary file out-of-band via configuration management (Puppet, Ansible) works, but a stuck agent run leaves that node open.
I usually verify KRL distribution with a local check that raises alerts if the local /etc/ssh/revoked_keys timestamp drifts too far from the CA's latest published generation sequence.
Using Short-Lived Certificates to Minimize Revocation Overhead
The cleanest way to deal with the KRL synchronization headache is to rely on short-lived certificates that expire so quickly that you rarely need a KRL for routine offboarding. If certificates are issued via an OIDC-aware CLI for 15 or 60 minutes, an offboarded user is naturally locked out of initiating new connections shortly after their identity provider account is disabled.
However, note the operational asymmetry: short-lived certs still do not kill running sessions. A 5-minute cert grants an active session that can stay open for two weeks if the server's TCP connection doesn't drop.
Auditing and Logging SSH Authentication Failures
When an incoming connection matches your KRL, OpenSSH logs the event via AUTH facility in syslog:
sshd[12481]: error: publickey /etc/ssh/revoked_keys:1 is revoked: ED25519 SHA256:abc123xyz...
sshd[12481]: Failed publickey for alice from 192.168.1.50 port 54322 ssh2: ED25519 SHA256:abc123xyz...
If your SIEM does not have an alert parsing error: publickey ... is revoked, add one. A connection attempt using an explicitly revoked key is almost always a misconfigured automation run or an attacker testing a decommissioned key.
Next Steps and Unresolved Quirks
The gap between identity-level revocation and OS-level session state remains messy without centralized session proxies (like Teleport or Boundary) intercepting traffic inline. Even with ephemeral certs, relying on ClientAliveInterval to drop idle sessions fails if the user runs a command generating periodic terminal output or keeps a background SSH tunnel sending keepalives.
I still need to spend time testing whether eBPF tracing on sys_enter_read across pseudo-terminal file descriptors can cleanly trigger automated logind session termination the moment an associated certificate's serial appears in a local revocation map, without depending on external orchestration to push loginctl terminate-user down to every edge node.
Explore Topics
Replace Shared SSH Keys with Browser Access
WarnHack Terminal: browser SSH, role-based access, CloudRelay session & command audit — Teleport/StrongDM alternative for lean teams.
Stay Ahead of Threats
Get the latest cybersecurity insights, tutorials, and threat intelligence delivered to your inbox.
Discussion
Enjoyed this article?