← All articles
Blog

Tracing lateral movement through SSH logs

A step-by-step method for following an attacker from one Linux host to the next: stolen keys, outbound connections and the matching logon on the far side.

1 December 2026 4 min read

On Windows, lateral movement investigations lean on logon event IDs and RDP artifacts. On Linux, nearly all of it runs over SSH. The evidence is there, but it is split across hosts and logs, and none of it says "lateral movement".

This article sets out a method for following an attacker from one Linux host to the next. Examples come from our Halden Freight demo case, where an attacker moved from a compromised web server to a database server.

The three pieces of evidence

A hop over SSH leaves traces in three places:

  1. On the source host: credential access, meaning a private key or password the attacker got hold of.
  2. On the source host: the outbound connection, such as an ssh process with a destination.
  3. On the destination host: the inbound logon, an Accepted publickey or Accepted password line from the source host's address.

You can rarely find all three directly. The method is to find one and use it to look for the others.

Step 1: find the credential

Look for reads of private keys and config files that hold passwords:

  • ~/.ssh/id_* files for every user, including service accounts such as deploy or ci;
  • ~/.ssh/config and known_hosts, which list where those keys are used;
  • application config files (wp-config.php, .env, settings.py) that may hold reused passwords.

With auditd execve records, a cat of a private key shows up as a process with the key path in its arguments. In Halden:

03:00:02  root  cat /home/deploy/.ssh/id_ed25519

Without auditd, the file's access time may show the read, if the file system records access times and nothing has touched the file since.

known_hosts is underrated. It tells you which hosts this account has connected to before, so it is a list of likely next hops.

Step 2: find the outbound connection

On the source host, look for the ssh client being run:

  • auditd execve: ssh with -i pointing at the stolen key and a user@host argument;
  • shell history: the same command, though usually without a time;
  • network evidence, if you have any: connection logs, flow data, or a live connection listing from a live collection.

In Halden, auditd recorded:

03:14:02  root  ssh -i /home/deploy/.ssh/id_ed25519 [email protected]

No process followed it on the web server in the first hour. That is consistent with an interactive session on the other host. It does not prove the logon succeeded, which is why step 3 matters.

Step 3: find the logon on the destination

On the destination host's auth.log:

sshd[...]: Accepted publickey for deploy from 10.20.1.10 port … ssh2: ED25519 SHA256:…

Three things to check:

  • The source address matches the host you came from.
  • The key fingerprint matches the stolen key. Compute it from the key file or the matching authorized_keys entry.
  • The time is consistent with step 2. Allow for clock drift between hosts and note the offset.

If the logon used a password, look for Accepted password and, often, a burst of failures before it.

Step 4: follow the session

A logon line is not the end. Rebuild what the session did:

  • sshd and PAM session open and close lines give the session's duration.
  • su and sudo records show privilege changes inside it.
  • auditd, shell history and the file system timeline show what it ran and changed.

Then repeat from step 1 on the new host. Look for credentials read there, outbound connections, and so on.

Scoping: one account, every host

Once you know an account was used by the attacker, list every host it logged in to, not just the first one you found:

filter event_type == "syslog" && message ~= "Accepted (publickey|password) for deploy "
group {host_id} (aggregate {logons = count this, first = (earliest timestamp), last = (latest timestamp)})

Compare against normal use. A deployment account that logs in from the build server every morning is expected. The same account arriving from the web server at 03:14 is not.

Pitfalls

  • Shared service accounts. If the same key is used by automation, separate the attacker's sessions by source address and time, not by account.
  • Jump hosts. A logon from a bastion hides the real source. Follow the chain back through the bastion's own logs.
  • Agent forwarding. With SSH agent forwarding, the attacker may never read a key file. Look for SSH_AUTH_SOCK in process environments, and for sessions that hop without a matching key read.
  • Log rotation. auth.log.1 and compressed .gz files hold older events. Make sure your tooling reads them.

Doing it without a spreadsheet

The method is simple, but done by hand it means many logs on many hosts and a spreadsheet of who logged in where. Arcsentry rebuilds logon, terminal and privilege sessions from these logs automatically. It draws them as a relation graph of hosts, users and source addresses. In Halden, the hop from web01 to db01 was on screen as soon as the Sessions view opened. The AI investigator can then work each host's sessions in parallel and cite the events behind every hop.

How we wrote this

Drafted with AI from evidence in our own lab, with Laura Pompeu responsible for the article. The evidence comes from Halden Freight portal breach (Linux), built and investigated in our lab, so every example can be checked against real records.

Photo of Laura Pompeu
Laura Pompeu
Marketing Manager & Cybersecurity Content Strategist, Proven Data

Laura Pompeu is a Marketing Manager and Cybersecurity Content Strategist with 10+ years of experience across journalism, SEO, and digital marketing. She produces expert-level content on ransomware, incident response, and data recovery for technical and business audiences, and has led multinational content teams across global markets.

LinkedIn

See it on your own evidence. Free for 7 days.

Tell us what you want to investigate. A person replies within one business day with the download and a trial licence.

Request a trial