T1098.004

SSH Authorized Keys

Sub-technique of T1098 Account Manipulation

Adding your public key to authorized_keys to log in over SSH without a password.

How it shows up on Hack The Box

If you can write as another user (or as root) in their home, generating a key and adding it to ~/.ssh/authorized_keys gives you a stable shell that survives reboots.

Techniques in our catalog that match this one (the number is their machines):

Machines to practice it

Sorted from easiest to hardest. The ▶ link takes you to the minute of the IppSec video where it is used.

Commands

Taken from our cheatsheets and tool pages. Type your details and they are filled into every command.

C2 and post-exploitation › Persistence

Your SSH key in authorized_keys Target
mkdir -p ~/.ssh && echo 'ssh-ed25519 AAAA... tu_clave' >> ~/.ssh/authorized_keys
Add a root SSH key (if you can write) Target
echo 'ssh-ed25519 AAAA... tu_clave' | sudo tee -a /root/.ssh/authorized_keys