Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / LINUX / LATERAL MOVEMENT

SSH Lateral Movement

This note documents detection patterns related to SSH Lateral Movement on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
Shell historyssh user@hostRemote host access initiatedCriticalPrimary lateral movement indicator.
Shell historyscpFile transfer to another hostCriticalCommon lateral staging method.
Shell historyrsync -e sshSSH-based transferHighOften used for stealthier movement.
Shell historyssh -iExplicit key usageCriticalIndicates controlled credential use.
Shell historyProxyCommandPivoted SSH movementCriticalAdvanced lateral movement signal.
Shell historysshpassPassword-based automated movementCriticalStrong operator indicator.
auth.log / secureoutbound SSH accepted on targetTarget-side remote loginCriticalConfirms remote entry.
auth.log / securelocal accepted outbound identitySource-side key usage contextHighSource attribution.
known_hostsnew remote host entryHost reachedCriticalStrong pivot artifact.
authorized_keyskey reused across hostsCredential spreadHighLateral persistence clue.
auditdexecve of ssh/scp/rsyncProcess attributionCriticalBest attribution if enabled.
journalctlssh invocationRuntime clueHighDepends on logging depth.
Network telemetryoutbound TCP/22 to internal hostInternal movementCriticalStrong network proof.
File timestampsknown_hosts updatedTimeline anchorHighCorrelates movement window.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
SSH immediately after footholdExpansion from first hostCriticalCommon attacker progression.
Internal IP targetsEast-west movementCriticalStrong lateral signal.
Same key on multiple hostsCredential reuseCriticalCross-host compromise clue.
SSH to dormant admin serverUnusual target choiceHighContext strengthens suspicion.
File transfer before login elsewherePayload stagingCriticalStrong operational sequence.
SSH from service accountHighly suspiciousCriticalOften exploitation context.
known_hosts suddenly populatedBroad movementHighStrong artifact when shell history missing.
ProxyCommand usedPivot chainCriticalAdvanced operator behavior.
SSH plus sudo on targetEscalation after movementCriticalMulti-host compromise chain.
Internal SSH burst to many hostsEnumeration + movementCriticalStrong campaign signal.

Common Tools

ToolUsage
sshStandard remote movement.
scpPayload transfer.
rsyncBulk file transfer.
sshpassPassword automation.
ProxyCommandPivot through intermediate host.
ProxyJumpModern SSH pivoting.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
Shell history.bash_history, .zsh_historyCriticalPrimary source movement evidence.
Known hosts~/.ssh/known_hostsCriticalRemote host contact truth.
SSH config~/.ssh/configHighCustom pivot definitions.
SSH keys~/.ssh/CriticalCredential source.
Auth logs/var/log/auth.log, /var/log/secureCriticalSource and target login evidence.
Audit logs/var/log/audit/audit.logCriticalProcess attribution.
Network logsflow / firewall / EDRCriticalInternal TCP/22 movement.
Target host logsremote auth evidenceCriticalConfirms second host compromise.

MITRE ATT&CK References

  • T1021 Remote Services
  • T1021.004 SSH
  • T1078 Valid Accounts
  • T1105 Ingress Tool Transfer

Decision Tree

  1. Was outbound SSH used?

    • Search shell history and network logs.
  2. Which target host?

    • Internal IP, hostname, role.
  3. Which credential?

    • Password, key, explicit identity.
  4. Was file transfer involved?

    • SCP, rsync, copied payloads.
  5. Did target show login?

    • Confirm on remote logs.
  6. Pivot

    • known_hosts → host list.
    • SSH key → credential spread.
    • Target → persistence or escalation.
  7. Confirm lateral movement

    • Outbound SSH + target login + credential artifact = strong lateral movement.

Example Detection Templates

Grep

grep -R "ssh \|scp \|rsync -e ssh\|sshpass\|ProxyCommand\|ProxyJump" /home/*/.bash_history /root/.bash_history 2>/dev/null
grep -R "Host " /home/*/.ssh/config /root/.ssh/config 2>/dev/null
grep -R "" /home/*/.ssh/known_hosts /root/.ssh/known_hosts 2>/dev/null

Journalctl

journalctl | grep ssh

File Inspection

stat ~/.ssh/known_hosts
find /home /root -name known_hosts 2>/dev/null

Sigma

title: Linux SSH Lateral Movement
id: linux-ssh-lateral-movement
status: experimental
description: Detects SSH usage patterns consistent with internal lateral movement
logsource:
  product: linux
detection:
  selection_keywords:
    message|contains:
      - 'ssh '
      - 'scp '
      - 'sshpass'
      - 'ProxyCommand'
  condition: selection_keywords
fields:
  - message
  - hostname
falsepositives:
  - Legitimate administration
level: high
tags:
  - attack.lateral_movement
  - attack.t1021.004

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
Key governanceLimit SSH key spreadCriticalReduces credential reuse.
Internal segmentationRestrict east-west SSHCriticalMajor movement barrier.
LoggingPreserve source and target SSH logsHighNeeded for chain reconstruction.
AuditdTrack ssh/scp execveHighStrong attribution.
MFA / bastionsCentralize privileged SSHHighReduces direct host-to-host movement.
Known host reviewMonitor unusual growthMediumUseful artifact anomaly.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Was ssh used outbound?grep historyImmediate movement check.
Which hosts were touched?known_hostsHost pivot list.
Was key used?inspect ssh -i / keysCredential clue.
Was file transferred?scp / rsync historyPayload movement clue.
Did target confirm login?target auth logsProof of movement.
Did target gain persistence?inspect remote artifactsChain continuation.

High Value Grep Strings

PatternWhy It Matters
ssh Primary movement command.
scp File transfer.
rsync -e sshBulk transfer.
ssh -iExplicit key use.
sshpassPassword automation.
ProxyCommandPivot indicator.
ProxyJumpAdvanced SSH pivoting.

Analyst Notes

ScenarioInterpretation
SSH to internal host after footholdStrong lateral movement.
known_hosts updated but no historyHistory tampering possible.
Same key reused widelyCredential spread likely.
SCP before target loginPayload staging pattern.
ProxyCommand presentMulti-hop operator movement.
Service account SSHHighly suspicious unless expected.