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

Successful SSH Compromise

This note documents detection patterns related to Successful SSH Compromise on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
/var/log/auth.log / /var/log/secureAccepted passwordSuccessful password-based SSH loginCriticalPrimary successful SSH authentication indicator.
/var/log/auth.log / /var/log/secureAccepted publickeySuccessful SSH key authenticationCriticalIndicates key-based access, legitimate or malicious.
/var/log/auth.log / /var/log/securesession opened for userSession fully establishedCriticalConfirms shell entry after authentication.
/var/log/auth.log / /var/log/securepam_unix(sshd:session)PAM session creationHighConfirms authenticated session lifecycle.
/var/log/auth.log / /var/log/secureReceived disconnectSession terminationMediumHelps define session boundaries.
/var/log/auth.log / /var/log/secureConnection closedSSH session endedMediumUseful for short-lived attacker sessions.
journalctlsshd accepted login recordsJournald authentication success evidenceCriticalEssential where flat logs absent.
wtmpSuccessful login entryHistorical session evidenceCriticalUsed by last.
lastSession listingLogin chronologyCriticalFast successful session review.
lastlogUser login timestampAccount usage baselineHighIdentifies recent unexpected account use.
Shell historycommand execution after loginImmediate operator activityCriticalOften strongest post-auth evidence.
auditdexecve after sshd sessionProcess lineage after loginCriticalBest process truth if enabled.
sshd child process telemetryper-session sshd childSession-linked process contextHighUseful in EDR / audit environments.
Network telemetryTCP/22 session fully establishedRemote shell channel confirmedHighUseful if host logs partial.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Successful login immediately after failuresAccepted password following brute force burstCriticalStrong compromise signal.
New geography or ASNSource IP inconsistent with normal operator behaviorHighImportant contextual signal.
Service account interactive loginNon-human account entering shellCriticalOften highly suspicious.
Root login successDirect privileged accessCriticalVery high severity if unexpected.
Short session followed by persistenceQuick login then cron/key/user changesCriticalCommon attacker stabilization pattern.
Login during maintenance silenceOff-hours accessHighContext strengthens suspicion.
New account used for first timeFresh account immediately used via SSHCriticalOften persistence validation.
SSH key login without known deploymentUnexpected key acceptanceCriticalOften hidden persistence.
Successful login followed by sudoImmediate escalation behaviorCriticalStrong attacker signal.
Same IP later opens outbound connectionsFoothold used operationallyCriticalIndicates active intrusion chain.

Common Tools

ToolUsage
Native sshStandard operator access after credential theft.
sshpassPassword-based automation or scripted attacker access.
Stolen private keysDirect key-based compromise.
ProxyChains / pivotsRouted SSH through prior footholds.
Cloud console credential reuseLegitimate-looking SSH via stolen infra credentials.
Automated post-brute scriptsImmediate command execution after successful login.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
SSH auth logs/var/log/auth.log, /var/log/secureCriticalPrimary login source.
Journald SSH logsjournalctl -u ssh, journalctl -u sshdCriticalRequired on many modern hosts.
Successful login database/var/log/wtmpCriticalUsed by last.
Login summarieslast, lastlogCriticalFast session review.
Failed login history/var/log/btmp, lastbHighMust correlate preceding brute force.
Shell history~/.bash_history, /root/.bash_historyCriticalSession actions after entry.
SSH key files~/.ssh/authorized_keysCriticalKey compromise / persistence linkage.
SSH daemon config/etc/ssh/sshd_configHighDetermine accepted auth methods.
Audit logs/var/log/audit/audit.logCriticalProcess lineage after login.
Sudo logsauth logs / journalCriticalImmediate escalation pivot.
Home directory timestampsstat /home/<user>HighSession artifact timing.

MITRE ATT&CK References

  • T1021.004 SSH
  • T1078 Valid Accounts
  • T1078.003 Local Accounts
  • T1098 Account Manipulation

Decision Tree

  1. Is successful SSH present?

    • Identify Accepted password or Accepted publickey.
  2. Which account logged in?

    • Determine whether user is expected, privileged, service-like, or newly created.
  3. From where?

    • Review source IP, ASN, geography, previous history.
  4. What preceded success?

    • Check brute force, password spray, previous failures.
  5. What happened immediately after login?

    • Shell history, sudo, file changes, outbound connections.
  6. Pivot

    • User → shell history / privilege use.
    • Source IP → recurrence / threat intel / host correlation.
    • Session window → persistence actions.
  7. Confirm compromise

    • Unexpected account + suspicious IP + immediate operator activity = likely intrusion.

Example Detection Templates

Grep

grep "Accepted password" /var/log/auth.log /var/log/secure 2>/dev/null
grep "Accepted publickey" /var/log/auth.log /var/log/secure 2>/dev/null
grep -E "Accepted password|Accepted publickey|session opened for user" /var/log/auth.log /var/log/secure 2>/dev/null
grep "Accepted password" /var/log/auth.log | tail -50

Journalctl

journalctl -u ssh | grep "Accepted"
journalctl -u sshd | grep "session opened"

Login Databases

last
lastlog

Sigma

title: Linux Successful SSH Login
id: linux-successful-ssh-login
status: experimental
description: Detects successful SSH authentication that may indicate valid account compromise
logsource:
  product: linux
  service: auth
detection:
  selection:
    message|contains:
      - 'Accepted password'
      - 'Accepted publickey'
      - 'session opened for user'
  condition: selection
fields:
  - message
  - hostname
  - source_ip
falsepositives:
  - Legitimate remote administration
  - Automation
level: medium
tags:
  - attack.initial_access
  - attack.t1021.004
  - attack.t1078

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
SSH authenticationPrefer key auth with strong key governanceHighReduces password compromise risk.
Password authDisable where possibleCriticalRemoves brute-force credential entry path.
Root loginDisable direct root SSHCriticalRemoves highest-risk direct privilege entry.
MFAAdd second factorHighStops valid password-only compromise.
Source restrictionsRestrict SSH to trusted rangesCriticalMajor reduction of exposure.
Logging retentionPreserve auth and session logsHighEssential for compromise reconstruction.
Key hygieneReview authorized keys regularlyHighPrevents silent key persistence.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Who logged in recently?lastEstablish active session timeline.
Was login password or key?grep accepted auth methodDetermines likely attack path.
Was success preceded by failures?grep failures before successIdentifies brute-force transition.
What commands ran after login?shell historyImmediate operator evidence.
Was sudo used?grep sudo in auth logsEscalation detection.
Was persistence added?inspect cron, keys, usersAttacker stabilization.

High Value Grep Strings

PatternWhy It Matters
Accepted passwordPrimary password success marker.
Accepted publickeyKey-based session established.
session opened for userSession fully opened.
pam_unix(sshd:session)PAM-backed successful session lifecycle.
Received disconnectSession boundary evidence.
Connection closedUseful for duration estimation.

Analyst Notes

ScenarioInterpretation
Success after brute force burstHigh-confidence credential compromise.
Publickey success on unexpected accountLikely SSH key persistence or stolen key.
Root success with unknown IPHigh severity immediate escalation lead.
Very short login + file changesFast operator stabilization behavior.
Success with no shell historyNon-interactive command, cleanup, or history tampering possible.
Service account loginOften highly suspicious unless explicitly expected.