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

SSH Brute Force

This note documents detection patterns related to SSH Brute Force on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
/var/log/auth.log / /var/log/secureFailed passwordFailed SSH password authenticationCriticalPrimary brute force indicator.
/var/log/auth.log / /var/log/secureInvalid userUsername probing against nonexistent accountsCriticalStrong reconnaissance precursor.
/var/log/auth.log / /var/log/secureauthentication failurePAM authentication failureHighOften seen across SSH and sudo failures.
/var/log/auth.log / /var/log/securemaximum authentication attempts exceededSession terminated after repeated failuresCriticalHigh-confidence brute pressure.
/var/log/auth.log / /var/log/secureDisconnected from authenticating userShort-lived failed SSH sessionsHighCommon after password spray loops.
/var/log/auth.log / /var/log/secureerror: PAM:Authentication subsystem rejectionMediumCan accompany brute force or malformed attempts.
/var/log/auth.log / /var/log/secureConnection closed by authenticating userAborted auth flowMediumOften follows rapid automated attempts.
/var/log/auth.log / /var/log/secureReceived disconnectClient-side disconnect after failed authMediumOften tooling driven.
journalctlsshd failuresJournald SSH failure streamCriticalPrimary source when flat logs absent.
btmpFailed login recordsHistorical failed login databaseCriticalSurvives even if auth.log rotated.
lastbFailed login outputAggregated failed loginsCriticalQuick brute force triage.
Syslog rotation archivesrepeated failuresHistoric brute force evidenceHighEssential if current logs incomplete.
Network telemetryrepeated TCP/22 attemptsExternal brute force source behaviorCriticalUseful when host logs partial.
EDR telemetryrepeated sshd auth failuresProcess-level repeated failuresHighCorrelates source IP and volume.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Many usernames tested from one IPMultiple target usernames in short intervalCriticalStrong brute force signature.
Same username attacked from many IPsDistributed password sprayHighOften botnet-based.
Failed attempts followed by successImmediate successful login after failuresCriticalVery high compromise likelihood.
Off-hours SSH failuresNight-time or unusual timingMediumUseful contextual signal.
Country mismatchSource IP from unusual geographyHighOperationally important in internet-facing servers.
Repeated root attemptsroot targeted heavilyHighCommon automated scanning behavior.
Sequential username enumerationadmin, test, oracle, ubuntu, etc.HighDictionary-driven attack pattern.
Failure spike across many hostsSame source against multiple serversCriticalCoordinated campaign indicator.
Short bursts every few secondsScripted cadenceHighTypical automated brute timing.
Source IP later used in successSame IP transitions into footholdCriticalImmediate escalation path.

Common Tools

ToolUsage
hydraParallel SSH brute forcing utility.
ncrackNetwork authentication brute forcing.
medusaMulti-protocol brute force framework.
patatorFlexible password attack tool.
sshpassUsed in crude scripted brute attempts.
Botnet SSH scannersCommon internet background noise and mass attacks.
Custom Python loopsLow sophistication scripted brute force attempts.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
SSH auth logs/var/log/auth.log, /var/log/secureCriticalPrimary brute force source.
Journald SSH logsjournalctl -u ssh, journalctl -u sshdCriticalHigh-value source on systemd hosts.
Failed login database/var/log/btmpCriticalOften survives partial cleanup.
Failed login viewerlastbCriticalFast failed-login summary.
Login success logs/var/log/wtmp, lastHighNeeded to correlate success after brute force.
SSH daemon config/etc/ssh/sshd_configHighValidate protections and exposed auth methods.
Firewall logsnftables / iptables / cloud firewallHighSource IP repetition and block history.
Fail2ban logs/var/log/fail2ban.logHighConfirms automated mitigation triggered.
Rotated auth logs/var/log/auth.log.*, /var/log/secure-*HighHistorical brute force visibility.
Network capturespcaps / netflowHighSource distribution and cadence.

MITRE ATT&CK References

  • T1110 Brute Force
  • T1110.001 Password Guessing
  • T1110.003 Password Spraying
  • T1021.004 SSH

Decision Tree

  1. Are repeated SSH failures present?

    • Count Failed password, Invalid user, PAM failures.
  2. Is activity concentrated or distributed?

    • Determine whether one IP, subnet, ASN, or many rotating IPs are involved.
  3. Are usernames random or targeted?

    • Review account selection pattern.
  4. Did failures transition into success?

    • Pivot immediately into successful SSH events.
  5. Was privileged account targeted?

    • Check root, service accounts, admin-like usernames.
  6. Pivot

    • Source IP → reputation / recurrence / geo.
    • Username → account validity / privilege.
    • Success event → shell history / sudo / persistence.
  7. Confirm compromise potential

    • Failed sequence + success + shell activity = likely breach.

Example Detection Templates

Grep

grep "Failed password" /var/log/auth.log /var/log/secure 2>/dev/null
grep "Invalid user" /var/log/auth.log /var/log/secure 2>/dev/null
grep -E "Failed password|Invalid user|authentication failure" /var/log/auth.log /var/log/secure 2>/dev/null
awk '/Failed password/ {print $(NF-3)}' /var/log/auth.log | sort | uniq -c | sort -nr

Journalctl

journalctl -u ssh | grep "Failed password"
journalctl -u sshd | grep "Invalid user"

Failed Login Databases

lastb
lastb | head -50

Sigma

title: Linux SSH Brute Force Attempts
id: linux-ssh-bruteforce-attempts
status: experimental
description: Detects repeated SSH authentication failures that may indicate brute force or password spraying
logsource:
  product: linux
  service: auth
detection:
  selection:
    message|contains:
      - 'Failed password'
      - 'Invalid user'
      - 'authentication failure'
  condition: selection
fields:
  - message
  - hostname
  - source_ip
falsepositives:
  - Misconfigured automation
  - Forgotten credentials
level: high
tags:
  - attack.credential_access
  - attack.t1110
  - attack.t1021.004

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
SSH authenticationDisable password auth where possibleCriticalStrongest brute force reduction.
Root accessDisable direct root SSH loginCriticalRemoves highest-value target.
Fail2banAuto-block repeated failuresHighImmediate brute pressure reduction.
Network controlsRestrict SSH source rangesCriticalMajor exposure reduction.
MFAAdd second factor where possibleHighStops password-only compromise.
Rate limitingLower allowed attemptsHighReduces brute throughput.
Logging retentionPreserve auth and btmp historyHighEssential for investigation.
External exposureMove SSH off direct internet where possibleHighReduces background attack volume.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Are failures ongoing?tail -f /var/log/auth.logDetect live brute force.
Which IP attacks most?count failed entries by IPIdentify primary source.
Which usernames targeted?extract usernames from failuresShows attacker intent.
Was there success after failures?grep Accepted passwordDetect breach transition.
Is fail2ban active?inspect fail2ban logsDetermine mitigation status.
Are root attempts present?grep rootHigh-risk target focus.

High Value Grep Strings

PatternWhy It Matters
Failed passwordPrimary brute force signal.
Invalid userUsername discovery and enumeration.
authentication failurePAM failure evidence.
maximum authentication attempts exceededHigh-pressure auth attempts.
Disconnected from authenticating userScripted short failure cycles.
Received disconnectCommon tooling disconnect signature.
Accepted passwordMust be checked immediately after brute force burst.

Analyst Notes

ScenarioInterpretation
Thousands of failures, no successLikely internet background noise unless targeted user set stands out.
Failures then single successHigh-confidence compromise lead.
Same source across multiple hostsCoordinated brute infrastructure.
Many usernames but one valid user later succeedsPassword spray likely.
Root repeatedly targetedGeneric scanner or privilege-seeking operator.
Failures disappear after successPossible attacker stopped after foothold.