Account Manipulation: SSH Authorized Keys T1098.004

Tactics: Persistence, Privilege Escalation

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.

Authoring guide

Patterns shared across the 12 rules above: which fields they filter on, what specific values they look for, and what they exclude. The catalog normalizes field names across vendors so Sigma's Image, Elastic's process.name, and Splunk's process_name collapse into one row. Each rule contributes at most once per row.

Fields filtered most (20 distinct)

The fields most rules look at when detecting this technique. The How column shows the operators authors use (eq, wildcard, regex_match, match) and how often each appears. Sample values are concrete examples to start from, not an exhaustive list.

FieldRulesHowSample values
EventType6in 4, eq 2exec, ProcessRollup2, SendSSHPublicKey, SendSerialConsoleSSHPublicKey, creation
host.os.type5eq 5
event.type4eq 2, in 2change, creation, start
process_name4in 4, eq 1bash, cat, csh, ctl, dash
CommandLine3contains 1, ends_with 1, wildcard 1* nc *, * nc.traditional *, * ncat *, /authorized_keys, /etc/ssh/sshd_config
TargetFilename3wildcard 2, contains 1/.ssh, /boot/efi/efi/*/grub.cfg, /boot/grub/grub.cfg, /boot/grub2/grub.cfg, /etc/ssh/*
container.id2starts_with 1, wildcard 1*, ?
data_stream.dataset2eq 2aws.cloudtrail, fim.event
event.category2eq 2authentication, file
event.outcome2eq 2success
file.name2in 2authorized_keys, authorized_keys2
process.args2in 2, contains 1, eq 1, wildcard 1* /dev/shm/* , * /home/*, * /run/*, --, --restart=Never
process.interactive2eq 2true
Image1eq 1/usr/bin/ssh-keygen
Provider_Name1eq 1ec2-instance-connect.amazonaws.com

Top indicator values (312 distinct)

Specific (field, operator, value) combinations the rules check for, ranked by how many rules under this technique use each one. The Corpus reach column counts how many rules across the entire catalog (any technique) check the same combination. High numbers point to widely-used indicators that are likely noisy on their own; combine them with another condition for useful signal. Blank means the combination is specific to rules under this technique. Click a value to expand the rules under this technique that use it.

FieldKindValueRules (here)Corpus reach
TargetFilenamewildcard
/etc/ssh/*
22
TargetFilenamewildcard
/home/*/.ssh/*
22
TargetFilenamewildcard
/root/.ssh/*
22
event.outcomeeq
success
2251
event.typeeq
start
2606
event.typein
change
216
event.typein
creation
215
file.namein
authorized_keys
23
file.namein
authorized_keys2
23
process.interactiveeq
true
242
process_namein
bash
288
process_namein
cat
223
CommandLinecontains
/authorized_keys
1
CommandLineends_with
/etc/ssh/sshd_config
1
CommandLinewildcard
* nc *
12
CommandLinewildcard
* nc.traditional *
1
CommandLinewildcard
* ncat *
1
CommandLinewildcard
* netcat *
1
CommandLinewildcard
*./.*
1
CommandLinewildcard
*/boot/*
1
CommandLinewildcard
*/dev/shm/*
13
CommandLinewildcard
*/dev/tcp/*
12
CommandLinewildcard
*/etc/init.d*
12
CommandLinewildcard
*/etc/ld.so*
12
CommandLinewildcard
*/etc/profile*
12
CommandLinewildcard
*/etc/rc.local*
12
CommandLinewildcard
*/etc/shadow*
15
CommandLinewildcard
*/etc/ssh*
14
CommandLinewildcard
*/etc/sudoers*
12
CommandLinewildcard
*/etc/update-motd.d*
12

Exclusions (22 distinct)

Field/operator/value combinations excluded by rules under this technique (top-level not() clauses), sorted by how many rules exclude each. These are the false-positive paths the community has learned to filter out. A new rule that ignores the high-count entries here will likely fire on the same noisy paths. Click a value to expand the rules under this technique that exclude it.

FieldKindValueRules excluding
Imageeq
/library/developer/commandlinetools/usr/bin/git
1
Imageeq
/opt/jc/bin/jumpcloud-agent
1
Imageeq
/opt/puppetlabs/puppet/bin/puppet
1
Imageeq
/usr/bin/bsdtar
1
Imageeq
/usr/bin/chef-client
1
Imageeq
/usr/bin/google_guest_agent
1
Imageeq
/usr/bin/nautilus
1
Imageeq
/usr/bin/scp
1
Imageeq
/usr/bin/touch
1
Imageeq
/usr/bin/vim
1
Imagestarts_with
/var/lib/docker/
1
Imagewildcard
/library/java/javavirtualmachines/jdk*.jdk/contents/home/bin/java
1
Imagewildcard
/usr/local/cellar/coreutils/*/bin/gcat
1
Imagewildcard
/usr/local/cellar/maven/*/libexec/bin/mvn
1
TargetFilenamewildcard
/home/*/.ssh/known_hosts.*
1

Rules under this technique

Every rule in the catalog tagged with this technique, grouped by vendor. Click a rule title for its full predicates, exclusions, and indicators.

Platform (all)
Domain (all)

Elastic 8 rules

Splunk 4 rules