SSH and Linux Lateral Movement
What you'll learn: How attackers pivot through compromised Linux systems using SSH keys, agent forwarding, and tunneling to reach deeper network targets.
The Core Idea
Once you've compromised a Linux host, SSH becomes your expressway for lateral movement. Unlike Windows environments with SMB and WMI, Linux networks typically rely on SSH for remote administration. Attackers exploit this by stealing SSH keys, abusing agent forwarding, or creating tunnels to pivot through networks—essentially turning each compromised host into a stepping stone toward high-value targets.
SSH Keys: The Silent Pivot
Private SSH keys stored in ~/.ssh/id_rsa (or similar) are gold for lateral movement. If you find keys without passphrases, you can authenticate to other systems silently, no password required. Check ~/.ssh/authorized_keys on the current host to see where this machine can be accessed from, and check ~/.ssh/known_hosts to discover where users have connected to.
SSH Agent Forwarding: Hijacking Trust
When users enable SSH agent forwarding (ssh -A), their authentication agent travels with them. An attacker with root on an intermediate host can hijack that forwarded agent socket and authenticate as the original user to any system they have access to—even without stealing actual keys.
SSH Tunneling: The Hidden Highway
SSH's port forwarding capabilities (-L, -R, -D) let you create encrypted tunnels through compromised hosts. Local forwarding (-L) pulls remote services to your attack machine, remote forwarding (-R) pushes services from your machine to the target network, and dynamic forwarding (-D) creates a SOCKS proxy for pivoting through the compromised host to reach otherwise inaccessible network segments.
Think of it like having a trusted courier service (SSH) that lets you package and route traffic anywhere in the network, all encrypted and legitimate-looking.
Key Takeaway: SSH lateral movement leverages stolen keys for silent authentication, hijacks agent forwarding for credential reuse, and uses tunneling to reach isolated network segments—turning every compromised Linux host into a pivot point.