Linux SSH Authorized Keys Persistence
Adding your public key to a user's authorized_keys file gives passwordless SSH access that survives password changes, reboots, and session termination. It requires write access to the target user's home directory — either directly or through a path traversal, file write vulnerability, or elevated shell.
Generate a key pair on your attack box
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... attacker@kali
Add key to target user
SSH config persistence
Beyond authorized_keys, the sshd configuration can be modified to allow root login or password authentication if currently disabled — making other accounts or methods viable for re-entry.
SSH config changes are visible and often monitored. The authorized_keys method is less detectable because it adds a key to an existing file rather than modifying a system configuration file. On systems with AuthorizedKeysCommand configured, the static authorized_keys file may be bypassed — check the sshd config before relying on this technique.
Cleaning up
Was this helpful?
Your feedback helps improve this page.