A persistence technique where an attacker writes a public key into a user's authorized_keys file to create ongoing shell access. The access survives package removal and often remains valid until the key is manually removed, which makes it a durable host compromise indicator.
What SSH Authorized Keys Persistence Means
SSH authorized keys persistence is a shell-access persistence method, not a new exploit path. An attacker places a public key into authorized_keys so future SSH logins remain possible even if the original foothold is removed or the password changes.
The technique works because SSH trusts the key listed for that account, so the attacker does not need to keep reusing the same malware, scheduled task, or web shell. In practice, the key becomes a durable access token for any system that still accepts SSH for that user.
How the Technique Works in Practice
The attacker usually targets a writable home directory, a compromised privileged account, or a configuration path that can update the file. Once the public key is added, SSH treats it as an approved authenticator for that account until an administrator removes it.
This is especially effective in environments where administrators assume that deleting malware or changing a password ends the incident. A persistent key can survive those cleanup steps because it is part of account configuration, not a running process.
The SSH Key and SSH Certificate Management Guide is useful background for understanding why key inventory, orphaned key removal and rotation matter so much in SSH estates.
Why It Matters for Detection and Response
SSH key persistence is a strong indicator of durable host compromise because it gives the intruder repeatable access without re-exploitation. It often coexists with privilege abuse, lateral movement and hidden access paths that survive normal remediation.
Defenders should treat unauthorized SSH keys as both an access issue and an incident-response artifact. The presence of a foreign key in authorized_keys usually means the attacker had enough access to establish a trusted login method, which is more serious than a one-time command execution event.
The Identity Threat Detection and Response (ITDR) Guide helps frame persistent access as an identity abuse problem, while the MITRE ATT&CK Enterprise Matrix is a useful reference for mapping persistence, credential access and lateral movement behaviors.
Common Cleanup Mistakes and Control Gaps
authorized keys persistence is often missed when response teams focus only on binaries, services, or obvious malware. If account files, golden images, home directories, jump hosts and automation accounts are not checked, the attacker can simply log back in after the environment is “cleaned.”
This technique is also harder to notice in shared-admin or infrastructure accounts, where many keys may legitimately exist. The real control gap is weak ownership of SSH access, poor key lifecycle management and insufficient review of who can place or retain keys.
The IAM and IGA Basics page is a strong companion for understanding access review and entitlement governance, and the NHI Lifecycle Management Guide reinforces the lifecycle discipline needed to find stale or orphaned access material.
Risk and Threat Considerations
SSH authorized keys persistence creates durable unauthorized access because the backdoor lives in account configuration rather than in an obvious malicious binary. It is attractive to attackers who want low-noise reentry after initial compromise, cleanup, or password resets.
Failure mechanism: An adversary with write access to the account or its home directory adds a public key to authorized_keys, then uses normal SSH authentication to return later. If defenders do not inventory keys or validate ownership, the persistence remains invisible.
Impact: The attacker retains repeatable shell access, can re-establish control after remediation, and may use the same foothold for privilege escalation, lateral movement, or long-term surveillance.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| MITRE ATT&CK | TA0003 — Persistence | SSH authorized keys persistence is a host persistence technique. |
| Recommendation — Map unauthorized key insertion to persistence activity and hunt for repeat access paths. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | SSH keys are authenticators whose lifecycle must be controlled and removed when no longer approved. |
| AC-2 — Account Management | Unauthorized SSH keys reflect weak account and access lifecycle governance. | |
| AU-6 — Audit Record Review, Analysis, and Reporting | Detecting key persistence depends on reviewing account and authentication activity. | |
| Recommendation — Inventory SSH keys, rotate or revoke stale keys, and remove unauthorized authenticators promptly. Review account access regularly and disable or remediate accounts that retain unapproved SSH keys. Correlate authentication logs with file and account changes to spot unauthorized SSH key additions. | ||
| CIS Controls v8 | 5 — Account Management | SSH key persistence is controlled through account and access management hygiene. |
| Recommendation — Maintain ownership and periodic review of privileged accounts and their SSH access material. | ||
Practitioner Guidance
What to watch for: Treat unexpected key additions, duplicate keys across accounts, and keys that no longer have a clear owner as high-priority findings. In response work, validate every authorized key against an approved source of truth and remove anything that cannot be justified.
Governance implication: SSH access needs the same lifecycle discipline as other privileged access. Key ownership, rotation, offboarding, and periodic review should be explicit, especially for admin, automation, and shared infrastructure accounts.
The PAM Buyer's Guide is helpful when choosing controls that reduce long-lived SSH access, and the NIST SP 800-53 Rev 5 Security and Privacy Controls provides control context for access control, authentication, auditability and configuration management.
Related resources from NHI Mgmt Group
- What is the difference between controlling SSH access with PAM and controlling it with authorized keys on the destination host?
- How should security teams manage SSH authorized keys to prevent persistent unauthorized access?
- What breaks when unauthorized SSH keys are left in authorized_keys?
- Authorized Keys Persistence
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 12, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org