Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

Triage SSH brute force alerts by reading the successes first

The alert says 4,000 failed SSH logins from one address in ten minutes. Most analysts open auth.log, count the failures and start with the biggest number. It feels thorough. It also puts the least interesting source at t

The alert says 4,000 failed SSH logins from one address in ten minutes. Most analysts open auth.log, count the failures and start with the biggest number. It feels thorough. It also puts the least interesting source at the top of the list.

Why the loudest source is usually harmless

A bot that tries thousands of passwords on port 22 is common and mostly fails. If your host disables password login or the usernames it tries do not exist, the whole campaign ends as a wall of "Failed password" lines and nothing else. It deserves a firewall rule and a line in a report.

The event worth your time is a login that worked.

Start from the successes

grep "Accepted" /var/log/auth.log

Each line gives you the method (password or publickey), the account and the source IP. Take each IP and ask how many times it failed first:

grep "Failed password" /var/log/auth.log \
  | awk '{print $(NF-3)}' | sort | uniq -c | sort -rn

The field position assumes the usual sshd line ending in "from IP port N ssh2". On RHEL-family systems the file is /var/log/secure.

Now compare the two lists. Picture an analyst with these results: one address with 4,000 failures and no success, and another with three failures followed by "Accepted password for deploy". The second one is the incident, and it would never have been found by sorting on volume.

Brute force or spray

The shape of the failures tells you which attack it is.

  • Brute force: many passwords against one account. High volume, easy to threshold.
  • Password spray: one or two passwords against many accounts, slowly. Low volume on purpose, so a rule that fires on failure count misses it.

The "invalid user" marker helps. It means the account does not exist on the host, which fits a bot guessing names. A valid account name tried from an outside address, with little guessing around it, suggests the attacker already knew it.

After the login

For any suspicious success, keep reading the same log. Look for a new session opening, sudo use, and the time gap between the last failure and the success. Then check what the account did. A login is a lead, and what the session did afterwards decides whether it becomes an incident.

Practise on a real log

The free SSH brute force detection lab gives you an auth.log with a loud failed campaign and a quiet spray that got in, which is exactly this exercise. When you want more of the same, the SOC Analyst Lab Workbook has 30 hands-on investigations covering alert triage, log analysis and Sigma and SIEM queries, with answer keys and datasets, and it does not need paid tools. The shop's Black Friday sale, up to 70% off selected books and bundles, ends 29 Nov 2026.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.