Skip to content
Contact Support

If a Key Is Compromised

A compromised key usually means the instances it reached are compromised too, so the checks below apply to every host the key could reach.

Rotation is the first step, and does not wait for a maintenance window. See Rotate SSH Keys for the procedure.

Check what the host trusts

Keys you did not add are a common way of keeping access:

ssh-keygen -lf ~/.ssh/authorized_keys
sudo ssh-keygen -lf /root/.ssh/authorized_keys

Check what has been used

The journal records which keys have been used to log in, and from where:

sudo journalctl -u ssh --grep "Accepted publickey"

Each line records the fingerprint that was accepted, so you can tell which sessions were yours and which were not. On older images that still write a text log, use sudo grep "Accepted publickey" /var/log/auth.log instead.

Check what the daemon allows

The daemon may also be accepting passwords:

sudo sshd -T | grep -E "permitrootlogin|passwordauthentication"

passwordauthentication should read no. permitrootlogin reads prohibit-password on the Ubuntu cloud images, which allows root in by key only, and no is the safer setting unless something genuinely needs root over SSH.

Then the rest

Note

An authorized_keys entry can be restricted to the addresses it will be accepted from, which limits the value of a stolen key:

from="10.0.0.0/24",restrict ssh-ed25519 AAAAC3Nz... name@laptop-2026-08