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.

Events covered

4 catalog events are tagged with this technique by at least one rule.

ProviderEventTitle
Linux-AuditdEvent ID 1302PATH
Linux-AuditdEvent ID 1307CWD
Sysmon-for-LinuxEvent ID 1Process Create
Sysmon-for-LinuxEvent ID 11File created

Authoring guide

These 13 rules share fields, values, and exclusions.

Fields filtered most (20 distinct)

These fields appear most often in rule filters.

FieldRulesHowSample values
EventType6in 4, eq 2exec, ProcessRollup2, creation, exec_event, file_create_event
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/*
data_stream.dataset3eq 3aws.cloudtrail, fim.event, network_traffic.redis
container.id2starts_with 1, wildcard 1*, ?
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
Image1eq 1/usr/bin/ssh-keygen
Provider_Name1eq 1ec2-instance-connect.amazonaws.com
match_count1gt 10

Top indicator values (316 distinct)

These values appear most often in rule predicates.

FieldKindValueRules (here)Corpus reach
TargetFilenamewildcard
/etc/ssh/*
22
TargetFilenamewildcard
/home/*/.ssh/*
22
TargetFilenamewildcard
/root/.ssh/*
22
event.outcomeeq
success
2375
event.typeeq
start
21087
event.typein
change
220
event.typein
creation
219
file.namein
authorized_keys
23
file.namein
authorized_keys2
23
process_namein
bash
2202
process_namein
cat
228
CommandLinecontains
/authorized_keys
1
CommandLineends_with
/etc/ssh/sshd_config
1
CommandLinewildcard
* nc *
17
CommandLinewildcard
* nc.traditional *
1
CommandLinewildcard
* ncat *
12
CommandLinewildcard
* netcat *
12
CommandLinewildcard
*./.*
12
CommandLinewildcard
*/boot/*
1
CommandLinewildcard
*/dev/shm/*
19
CommandLinewildcard
*/dev/tcp/*
15
CommandLinewildcard
*/etc/init.d*
14
CommandLinewildcard
*/etc/ld.so*
14
CommandLinewildcard
*/etc/profile*
13
CommandLinewildcard
*/etc/rc.local*
14
CommandLinewildcard
*/etc/shadow*
112
CommandLinewildcard
*/etc/ssh*
110
CommandLinewildcard
*/etc/sudoers*
14
CommandLinewildcard
*/etc/update-motd.d*
14
CommandLinewildcard
*/home/*/.ssh/*
111

Exclusions (22 distinct)

These values appear most often in top-level exclusions.

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

These vendors publish rules tagged with this technique.

Platform (all)
Domain (all)

Elastic 9 rules

Splunk 4 rules