MITRE ATT&CK / Techniques / T1098.004

Account Manipulation: SSH Authorized Keys

ID
T1098.004
Tactics
TA0003 Persistence, TA0004 Privilege Escalation
Sub-technique of
T1098 Account Manipulation
Platforms
ESXi, IaaS, Linux, macOS, Network Devices
Data sources
File Modification, Process Creation, Command Execution
Source
attack.mitre.org
MITRE last modified
12 May 2026

Adversaries may modify the SSH authorized_keys file to maintain persistence on a victim host. Linux distributions, macOS, and ESXi hypervisors commonly use key-based authentication to secure the authentication process of SSH sessions for remote management. The authorized_keys file in SSH specifies the SSH keys that can be used for logging into the user account for which the file is configured. This file is usually found in the user's home directory under &lt;user-home&gt;/.ssh/authorized_keys (or, on ESXi, /etc/ssh/keys-<username>/authorized_keys).[2] Users may edit the system’s SSH config file to modify the directives PubkeyAuthentication and RSAAuthentication to the value yes to ensure public key and RSA authentication are enabled, as well as modify the directive PermitRootLogin to the value yes to enable root authentication via SSH.[1] The SSH config file is usually located under /etc/ssh/sshd_config.

Adversaries may modify SSH authorized_keys files directly with scripts or shell commands to add their own adversary-supplied public keys. In cloud environments, adversaries may be able to modify the SSH authorized_keys file of a particular virtual machine via the command line interface or rest API. For example, by using the Google Cloud CLI’s “add-metadata” command an adversary may add SSH keys to a user account.[3][4] Similarly, in Azure, an adversary may update the authorized_keys file of a virtual machine via a PATCH request to the API.[5] This ensures that an adversary possessing the corresponding private key may log in as an existing user via SSH.[6][7] It may also lead to privilege escalation where the virtual machine or instance has distinct permissions from the requesting user.

Where authorized_keys files are modified via cloud APIs or command line interfaces, an adversary may achieve privilege escalation on the target virtual machine if they add a key to a higher-privileged user.

SSH keys can also be added to accounts on network devices, such as with the ip ssh pubkey-chain Network Device CLI command.[8]

Detection

Mitigations (3)

M1018 User Account Management

In cloud environments, ensure that only users who explicitly require the permissions to update instance metadata or configurations can do so.

M1022 Restrict File and Directory Permissions

Restrict access to the authorized_keys file.

M1042 Disable or Remove Feature or Program

Disable SSH if it is not necessary on a host or restrict SSH access for specific users/groups using /etc/ssh/sshd_config. Setting the PermitRootLogin directive to no will prevent the root user from logging in via SSH.[1]

Groups (3)

Software (3)

References

  1. Broadcom ESXi SSH
  2. SSH Authorized Keys
  3. Google Cloud Add Metadata
  4. Google Cloud Privilege Escalation
  5. Azure Update Virtual Machines
  6. Venafi SSH Key Abuse
  7. Cybereason Linux Exim Worm
  8. cisco_ip_ssh_pubkey_ch_cmd