SSH Authorized Keys

T1098.004

Sub-technique of T1098 Account Manipulation.View on attack.mitre.org

About this technique

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`). 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. 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. Similarly, in Azure, an adversary may update the authorized_keys file of a virtual machine via a PATCH request to the API. This ensures that an adversary possessing the corresponding private key may log in as an existing user via SSH. 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.

Detection rules4

Rules on DetectionCode tagged with T1098.004.

Sigma0

No Sigma rules are mapped to this technique yet.

Splunk4

RuleTypeRiskData source
Linux Auditd Possible Access Or Modification Of Sshd Config FileAnomalyNULLLinux Auditd Path, Linux Auditd Cwd
Linux Possible Access Or Modification Of sshd Config FileAnomalyNULLSysmon for Linux EventID 1
Linux Possible Ssh Key File CreationAnomalyNULLSysmon for Linux EventID 11
Linux SSH Authorized Keys ModificationAnomalyNULLSysmon for Linux EventID 1

Groups3

Software3

Campaigns1

Procedure examples7

Groups3

Used byProcedure example
GroupEarth Lusca

Earth Lusca has dropped an SSH-authorized key in the `/root/.ssh` folder in order to access a compromised server with SSH.

GroupSalt Typhoon

Salt Typhoon has added SSH authorized_keys under root or other users at the Linux level on compromised network devices.

GroupTeamTNT

TeamTNT has added RSA keys in authorized_keys.

Software3

Used byProcedure example
MalwareBundlore

Bundlore creates a new key pair with ssh-keygen and drops the newly created user key in authorized_keys to enable remote login.

MalwareSkidmap

Skidmap has the ability to add the public key of its handlers to the authorized_keys file to maintain persistence on an infected host.

MalwareXCSSET

XCSSET will create an ssh key if necessary with the ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -P command. XCSSET will upload a private key file to the server to remotely access the host without a password.

Campaigns1

Used byProcedure example
CampaignOperation Digital Eye

During Operation Digital Eye, threat actors used SSH access enabled by authorized_keys files for remote execution.

References8

  1. Azure Update Virtual Machines Open source
    Microsoft. (n.d.). Virtual Machines - Update. Retrieved April 1, 2022.
  2. Broadcom ESXi SSH Open source
    Broadcom. (2024, December 12). Allowing SSH access to VMware vSphere ESXi/ESX hosts with public/private key authentication. Retrieved March 26, 2025.
  3. Cybereason Linux Exim Worm Open source
    Cybereason Nocturnus. (2019, June 13). New Pervasive Worm Exploiting Linux Exim Server Vulnerability. Retrieved June 24, 2020.
  4. Google Cloud Add Metadata Open source
    Google Cloud. (2022, March 31). gcloud compute instances add-metadata. Retrieved April 1, 2022.
  5. Google Cloud Privilege Escalation Open source
    Chris Moberly. (2020, February 12). Tutorial on privilege escalation and post exploitation tactics in Google Cloud Platform environments. Retrieved April 1, 2022.
  6. SSH Authorized Keys Open source
    ssh.com. (n.d.). Authorized_keys File in SSH. Retrieved June 24, 2020.
  7. Venafi SSH Key Abuse Open source
    Blachman, Y. (2020, April 22). Growing Abuse of SSH Keys: Commodity Malware Campaigns Now Equipped with SSH Capabilities. Retrieved June 24, 2020.
  8. cisco_ip_ssh_pubkey_ch_cmd Open source
    Cisco. (2021, August 23). ip ssh pubkey-chain. Retrieved July 13, 2022.

Data from MITRE ATT&CK® (Enterprise). ATT&CK® is a registered trademark of The MITRE Corporation.