sshd-logs: a single failed login produces 3-4 ssh_failed-auth events, so ssh-bf bans after 2 attempts
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
Research direction
The report identifies crowdsecurity/sshd-logs and ssh-bf as the relevant parser and scenario; start by reading those definitions and how the scenario counts ssh_failed-auth events. Compare the Debian/Ubuntu journal lines with the six alert events to identify where one connection contributes multiple counts. Done means the scenario’s attempt counting matches the behavior intended by the issue while preserving detection of repeated failed logins.
Written by the indexing model from the issue text.
Description
Describe the bug
One failed SSH login produces 3-4 ssh_failed-auth events, because crowdsecurity/sshd-logs tags every line of the attempt (Invalid user, pam_unix … authentication failure, Failed password, Connection closed / Disconnected from … [preauth]) with the same log_type. The scenarios count events, so ssh-bf (capacity 5, leakspeed 10s) fires after two attempts, not five.
Verified on crowdsec v1.8.1 with today's hub (sshd-logs 3.1, ssh-bf 0.3).
To Reproduce
A real ssh-bf alert from an engine that receives sshd logs from several hosts. One bot tried a single root password on each of two hosts, seven seconds apart. That's 2 attempts, 6 events, ban. (It did go on to brute-force both hosts over the next 30 seconds, so the ban itself was deserved; the point is that it fired on the second attempt.)
cscli alerts inspect <id> -d
- Date : 2026-10-19T02:45:07Z
- Machine : localhost
- Simulation : false
- Remediation : true
- Kind : crowdsec
- Reason : crowdsecurity/ssh-bf
- Events Count : 6
- Scope:Value : Ip:118.145.182.105
- Country : CN
- AS : Beijing Volcano Engine Technology Co., Ltd.
- Begin : 2026-10-19T02:44:57Z
- End : 2026-10-19T02:45:07Z
╭──────────────────────────────────────────────────────────────────────────╮
│ Active Decisions │
├────────┬────────────────────┬────────┬────────────┬──────────────────────┤
│ ID │ scope:value │ action │ expiration │ created_at │
├────────┼────────────────────┼────────┼────────────┼──────────────────────┤
│ <id> │ Ip:118.145.182.105 │ ban │ 7h57m25s │ 2026-10-19T02:45:07Z │
╰────────┴────────────────────┴────────┴────────────┴──────────────────────╯
- Context :
╭─────────────┬───────╮
│ Key │ Value │
├─────────────┼───────┤
│ target_user │ root │
╰─────────────┴───────╯
- Events :
- Date: 2026-10-19 02:44:56 +0000 UTC
╭─────────────┬─────────────────────────────────────────────╮
│ Key │ Value │
├─────────────┼─────────────────────────────────────────────┤
│ ASNNumber │ 137718 │
│ ASNOrg │ Beijing Volcano Engine Technology Co., Ltd. │
│ IsInEU │ false │
│ IsoCode │ CN │
│ SourceRange │ 118.145.176.0/20 │
│ log_type │ ssh_failed-auth │
│ server │ host-A │
│ service │ ssh │
│ source_ip │ 118.145.182.105 │
│ target_user │ root │
│ timestamp │ 2026-10-19T02:44:56.528158Z │
╰─────────────┴─────────────────────────────────────────────╯
- Date: 2026-10-19 02:44:59 +0000 UTC
╭─────────────┬─────────────────────────────────────────────╮
│ Key │ Value │
├─────────────┼─────────────────────────────────────────────┤
│ ASNNumber │ 137718 │
│ ASNOrg │ Beijing Volcano Engine Technology Co., Ltd. │
│ IsInEU │ false │
│ IsoCode │ CN │
│ SourceRange │ 118.145.176.0/20 │
│ log_type │ ssh_failed-auth │
│ server │ host-A │
│ service │ ssh │
│ source_ip │ 118.145.182.105 │
│ target_user │ root │
│ timestamp │ 2026-10-19T02:44:59.059554Z │
╰─────────────┴─────────────────────────────────────────────╯
- Date: 2026-10-19 02:45:02 +0000 UTC
╭─────────────┬─────────────────────────────────────────────╮
│ Key │ Value │
├─────────────┼─────────────────────────────────────────────┤
│ ASNNumber │ 137718 │
│ ASNOrg │ Beijing Volcano Engine Technology Co., Ltd. │
│ IsInEU │ false │
│ IsoCode │ CN │
│ SourceRange │ 118.145.176.0/20 │
│ log_type │ ssh_failed-auth │
│ server │ host-A │
│ service │ ssh │
│ source_ip │ 118.145.182.105 │
│ target_user │ root │
│ timestamp │ 2026-10-19T02:45:02.107132Z │
╰─────────────┴─────────────────────────────────────────────╯
- Date: 2026-10-19 02:45:03 +0000 UTC
╭─────────────┬─────────────────────────────────────────────╮
│ Key │ Value │
├─────────────┼─────────────────────────────────────────────┤
│ ASNNumber │ 137718 │
│ ASNOrg │ Beijing Volcano Engine Technology Co., Ltd. │
│ IsInEU │ false │
│ IsoCode │ CN │
│ SourceRange │ 118.145.176.0/20 │
│ log_type │ ssh_failed-auth │
│ server │ host-B │
│ service │ ssh │
│ source_ip │ 118.145.182.105 │
│ target_user │ root │
│ timestamp │ 2026-10-19T02:45:03.902024Z │
╰─────────────┴─────────────────────────────────────────────╯
- Date: 2026-10-19 02:45:05 +0000 UTC
╭─────────────┬─────────────────────────────────────────────╮
│ Key │ Value │
├─────────────┼─────────────────────────────────────────────┤
│ ASNNumber │ 137718 │
│ ASNOrg │ Beijing Volcano Engine Technology Co., Ltd. │
│ IsInEU │ false │
│ IsoCode │ CN │
│ SourceRange │ 118.145.176.0/20 │
│ log_type │ ssh_failed-auth │
│ server │ host-B │
│ service │ ssh │
│ source_ip │ 118.145.182.105 │
│ target_user │ root │
│ timestamp │ 2026-10-19T02:45:05.729562Z │
╰─────────────┴─────────────────────────────────────────────╯
- Date: 2026-10-19 02:45:06 +0000 UTC
╭─────────────┬─────────────────────────────────────────────╮
│ Key │ Value │
├─────────────┼─────────────────────────────────────────────┤
│ ASNNumber │ 137718 │
│ ASNOrg │ Beijing Volcano Engine Technology Co., Ltd. │
│ IsInEU │ false │
│ IsoCode │ CN │
│ SourceRange │ 118.145.176.0/20 │
│ log_type │ ssh_failed-auth │
│ server │ host-B │
│ service │ ssh │
│ source_ip │ 118.145.182.105 │
│ target_user │ root │
│ timestamp │ 2026-10-19T02:45:06.852918Z │
╰─────────────┴─────────────────────────────────────────────╯
The journals behind it (Debian/Ubuntu wording):
host-A: journalctl --since "30 minute ago" -u ssh | grep 118.145.182.105
Oct 19 02:44:52 host-A sshd[429256]: Connection closed by 118.145.182.105 port 40046
Oct 19 02:44:56 host-A sshd[429257]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:44:59 host-A sshd[429257]: Failed password for root from 118.145.182.105 port 38832 ssh2
Oct 19 02:45:02 host-A sshd[429257]: Connection closed by authenticating user root 118.145.182.105 port 38832 [preauth]
Oct 19 02:45:06 host-A sshd[429364]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:45:08 host-A sshd[429364]: Failed password for root from 118.145.182.105 port 58452 ssh2
Oct 19 02:45:09 host-A sshd[429364]: Connection closed by authenticating user root 118.145.182.105 port 58452 [preauth]
Oct 19 02:45:11 host-A sshd[429390]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:45:12 host-A sshd[429390]: Failed password for root from 118.145.182.105 port 58468 ssh2
Oct 19 02:45:13 host-A sshd[429390]: Connection closed by authenticating user root 118.145.182.105 port 58468 [preauth]
Oct 19 02:45:16 host-A sshd[429396]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:45:18 host-A sshd[429396]: Failed password for root from 118.145.182.105 port 50790 ssh2
Oct 19 02:45:18 host-A sshd[429396]: Connection closed by authenticating user root 118.145.182.105 port 50790 [preauth]
Oct 19 02:45:21 host-A sshd[429404]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:45:23 host-A sshd[429404]: Failed password for root from 118.145.182.105 port 50798 ssh2
host-B: journalctl --since "30 minute ago" -u ssh | grep 118.145.182.105
Oct 19 02:44:33 host-B sshd[3785466]: Connection closed by 118.145.182.105 port 35158
Oct 19 02:45:03 host-B sshd[3785467]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:45:05 host-B sshd[3785467]: Failed password for root from 118.145.182.105 port 37006 ssh2
Oct 19 02:45:06 host-B sshd[3785467]: Connection closed by authenticating user root 118.145.182.105 port 37006 [preauth]
Oct 19 02:45:11 host-B sshd[3785595]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:45:13 host-B sshd[3785595]: Failed password for root from 118.145.182.105 port 40110 ssh2
Oct 19 02:45:14 host-B sshd[3785595]: Connection closed by authenticating user root 118.145.182.105 port 40110 [preauth]
Oct 19 02:45:16 host-B sshd[3785603]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:45:18 host-B sshd[3785603]: Failed password for root from 118.145.182.105 port 46402 ssh2
Oct 19 02:45:19 host-B sshd[3785603]: Connection closed by authenticating user root 118.145.182.105 port 46402 [preauth]
Oct 19 02:45:20 host-B sshd[3785607]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:45:23 host-B sshd[3785607]: Failed password for root from 118.145.182.105 port 46410 ssh2
Oct 19 02:45:23 host-B sshd[3785607]: Connection closed by authenticating user root 118.145.182.105 port 46410 [preauth]
Oct 19 02:45:26 host-B sshd[3785613]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.145.182.105 user=root
Oct 19 02:45:28 host-B sshd[3785613]: Failed password for root from 118.145.182.105 port 41842 ssh2
The alert's six events are the three lines of host-A's first connection (pam_unix 02:44:56, Failed password 02:44:59, Connection closed by authenticating user 02:45:02) and the three lines of host-B's first connection (02:45:03, 02:45:05, 02:45:06). The decision was created at 02:45:07, before either host's second attempt. So the ban landed after two submitted passwords in total. cscli explain --type syslog on these lines gives 3 ssh_failed-auth events per attempt for a real user and 4 for an invalid one (Invalid user adds a fourth). The bare Connection closed by <ip> port <n> lines at 02:44:52 / 02:44:33 (no [preauth]) are the only ones that don't match.
Expected behavior
One failed login = one ssh_failed-auth event, so "capacity 5" means five attempts. That's also what the .tests/ssh-bf input assumes (one line per attempt).
Additional context
- The capacities date from 2020, when the parser emitted one line per attempt. The extra lines came in via #188 (pam_unix), #324 and #357 (preauth closes for password-off hosts), #525 and #1168.
- #1650 had the same diagnosis and split
ssh_failed-authintossh_password_failetc., but was closed unmerged. I'm guessing becausessh_failed-authis also used bydropbear-logsandPumbaLP/cowrie? Keepingssh_failed-authfor theFailed <method>line and giving only the other lines new types would avoid that. - #1859 was closed as a corner case, and the 2023 Discourse thread (https://discourse.crowdsec.net/t/collections-sshd-parser-triple-counts-failures/1169) didn't get a resolution.
- fail2ban's sshd filter doesn't count
pam_unix(<F-NOFAIL>) or[preauth]closes in normal mode, since 0.10.3 (fail2ban/fail2ban#2462).
What's the recommended way to deal with this? Is a fix along the lines of #1650 still planned, or should users be adjusting capacities / adding a local parser to get one event per attempt? Happy to put up a PR if you can say which direction you'd accept.
- Dominant language
- Python
- Stars
- 257
- Forks
- 235
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 26
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from crowdsecurity/hub
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
crowdsecurity/hub#2020 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
crowdsecurity/hub#2009 ·
Maintainers usually reply within 1 day
-
The Authelia parser (v0.9) doesn't classify `Unsuccessful 1FA authentication attempt by user ''`Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
crowdsecurity/hub#2001 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
crowdsecurity/hub#1999 ·
Maintainers usually reply within 1 day
-
Time format with time zone in Home Assistant parserPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
crowdsecurity/hub#1998 · 6 comments ·
Maintainers usually reply within 1 day
All issues in crowdsecurity/hub
Similar issues
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 62/100
DaoCloud/DaoCloud-docs#7839 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
sav-oss-org/ptusa_main#1610 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug status/accepted type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/apm#4925 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sagemathinc/sagebrush#1701 ·
Maintainers usually reply within 1 day