How to Detect SSH Brute-Force Attacks on Your Linux Server
Right now, someone is trying to guess the password to your server. If your machine has a public IP and SSH exposed on port 22, brute-force attempts are not a question of "if" but "how many per hour." Most server operators discover this only after something goes wrong.
This guide explains what SSH brute-force attacks are, how to check if your server is under attack right now, why the standard defenses have real gaps, and how to close those gaps with automated detection and response.
What is an SSH brute-force attack?
An SSH brute-force attack is straightforward: an attacker connects to your server's SSH port and tries username/password combinations until one works. The tools are free, the IP lists are public, and botnets run these scans at industrial scale 24/7.
A typical attack sends hundreds of login attempts per minute. Each failure is logged by your system, but unless something is watching those logs in real time, the attacker gets unlimited tries.
Are you being attacked right now?
Open a terminal on your server and run this:
grep "Failed password" /var/log/auth.log | tail -20If you see output, those are real login failures. Look at the IP addresses. If the same IP appears dozens of times, that is an active brute-force attack. On most public-facing servers, this list is never empty.
To see a count of the worst offenders:
grep "Failed password" /var/log/auth.log | awk '{print $(NF-3)}' | sort | uniq -c | sort -rn | head -10The numbers are usually worse than you expect.
Why fail2ban alone is not enough
fail2ban is a solid tool and a good first step. It watches log files, matches lines against regex patterns, and bans IPs after a threshold. But there are specific limitations that matter in production:
- Regex-only detection - fail2ban matches log lines with regular expressions. It does not understand context, correlation across sources, or attack patterns that span multiple services.
- No confidence scoring - every match is treated equally. There is no way to weigh the severity of an attack or factor in threat intelligence data before blocking.
- A ban record, not a case file - fail2ban keeps its bans in a SQLite database with up to ten matched log lines each, but records no enrichment and no confidence. When something breaks, tracing back to the root cause still means reading logs.
Notifications and threat intelligence are not the gap: fail2ban ships actions that send mail, notify through Apprise (Telegram, Slack and more) and report to AbuseIPDB. fail2ban is not broken. It just solves a narrower problem than most people assume.
How InnerWarden detects SSH brute-force
InnerWarden's sensor daemon reads /var/log/auth.log (or journald on systemd hosts) in real time. The ssh_bruteforce detector tracks failed login attempts per IP in a sliding time window:
When the threshold is crossed, the sensor creates a structured incident. The agent picks it up, enriches it with AbuseIPDB data and GeoIP, runs it through the AI provider for confidence scoring, and executes the appropriate firewall skill. Every step is recorded in the JSONL audit trail.
When a brute force gets in
A brute force that keeps failing is noise. One that ends in a successful login is the incident, and it looks like nothing more than a normal login unless something remembers the failures that came before it. The sensor'ssuspicious_logindetector does: five or more failed attempts from an address followed by a success in the same window is raised asbrute_force_success, Critical; fewer failures before a success isfailed_then_success, High.
It also learns who logs in from where. A first privileged login, or a login from a new address outside a user's usual hours (once seven days of logins have formed a baseline), is raised at High or Medium. When the Critical one fires, treat the account as compromised: find the session inlast and the auth log, rotate that user's keys and password, and check what the session ran.
Credential stuffing: many usernames, a few tries each
Credential stuffing replays leaked username and password pairs across many accounts, one or two tries each, so a per-account failure threshold never trips. Thecredential_stuffingdetector counts something else: how many different usernames one address tries. By default, 6 distinct usernames within 300 seconds raises a High incident. It is off by default; turn it on under[detectors.credential_stuffing]in the sensor configuration (seeConfiguration).
Real example from production
On our production server, the IP 203.0.113.19 started sending SSH login attempts. InnerWarden detected it, scored it, and blocked it in under 4 seconds. Here is what the detection-to-response chain looked like:
Total elapsed time from first failed login to firewall block: 3.8 seconds. The operator received a Telegram notification with full context and took no manual action.
Set it up
Install the host stack on the Linux server with your licence. SSH brute-force detection is on by default, and the install comes up in monitor mode: the sensor starts watching auth logs straight away and nothing is blocked until you turn blocking on.
curl -fsSL https://www.innerwarden.com/install | sudo bash -s -- --license=/path/to/license.txtThe licence selects the paid tier: without it the same command installs the free one. The full steps, including how to check the installer before you run it, are in Install and first run.
Then enable automated IP blocking:
innerwarden enable block-ipEverything starts in dry-run mode. The system detects and logs, but does not block until you explicitly disable dry-run. Review the decisions first, then go live when you trust the output.
innerwarden get statusWhat to do next
SSH brute-force detection is one layer. Once it is running, consider adding:
- An SSH honeypot - capture attacker commands and credentials on a fake shell to learn what they are after.
- Threat intelligence sharing - report blocked IPs to AbuseIPDB and push blocks to Cloudflare WAF so other servers benefit too.
- AI-powered triage - add an AI provider (OpenAI, Anthropic, Groq, Ollama, and others) for confidence-scored decisions instead of threshold-only blocking.