On this page
- How is CrowdSec built?
- How do I install the agent?
- Which bouncer should I install?
- How do I keep my own address from being banned?
- How do I make sure SSH logs are read?
- How do I add Nginx and other services?
- How do I test that a ban really blocks traffic?
- What if port 8080 is already in use?
- How do I keep CrowdSec up to date?
- Questions
How is CrowdSec built?
CrowdSec splits detection and enforcement. The agent, also called the security engine, reads log sources, parses each line, and runs scenarios such as SSH brute force or HTTP path probing. When a scenario fires it creates an alert and a decision (usually a ban for a few hours) stored by the local API on 127.0.0.1:8080. Bouncers ask that API for decisions and enforce them: the firewall bouncer adds addresses to nftables or iptables sets, while other bouncers work inside Nginx or a reverse proxy. Parsers, scenarios and collections come from the CrowdSec Hub and are managed with the cscli tool. By default the engine also downloads a community block list built from reports by other installations, and shares the addresses it bans in return; you can switch that off in the config.
If you already run fail2ban, pick one of the two for the same logs.
How do I install the agent?
The project publishes Debian and RPM repositories with a setup script. Review it first, then run it and install the engine:
curl -fsSL https://install.crowdsec.net -o crowdsec-repo.sh
less crowdsec-repo.sh
sudo sh crowdsec-repo.shUbuntu and Debian:
sudo apt install crowdsecRocky Linux 9 and AlmaLinux 9:
sudo dnf install -y crowdsecThe installer looks for known services, installs matching collections such as crowdsecurity/linux and crowdsecurity/sshd, and starts the service. Check the version and what got installed:
sudo cscli version
sudo cscli collections list
systemctl status crowdsec --no-pagerWhich bouncer should I install?
Use the nftables flavour of the firewall bouncer, since all supported releases filter through nftables:
sudo apt install crowdsec-firewall-bouncer-nftables
sudo dnf install -y crowdsec-firewall-bouncer-nftablesRun the line for your distribution. The package registers itself with the local API and starts. It creates its own nftables tables, separate from UFW, firewalld or your own rules, so it works next to any of them. Confirm it is connected:
sudo cscli bouncers list
sudo nft list tablesThe bouncer list should show a recent Last API pull time, and the table list should include tables whose names start with crowdsec.
How do I keep my own address from being banned?
Add an allow list before you start testing. A parser whitelist works on every current version. Create /etc/crowdsec/parsers/s02-enrich/my-allowlist.yaml:
name: local/my-allowlist
description: "Addresses that must never be banned"
whitelist:
reason: "admin access"
ip:
- "203.0.113.7"
cidr:
- "2001:db8:4f2a::/48"sudo systemctl reload crowdsec
sudo cscli parsers list | grep allowlistRecent releases also offer a managed allow list with sudo cscli allowlists create admins --description "admin" and sudo cscli allowlists add admins 203.0.113.7. If you still get banned, a different network (a phone hotspot works) lets you reach the server and run sudo cscli decisions delete --ip 203.0.113.7. A decision blocks only one address, so key based SSH from anywhere else stays available.
How do I make sure SSH logs are read?
Look at the acquisition metrics. They show each source and how many lines were parsed:
sudo cscli metricsOn Ubuntu, SSH events land in /var/log/auth.log and the default acquisition covers them. Debian 12 and 13 keep them only in the journal unless rsyslog is installed, and on Rocky and AlmaLinux they go to /var/log/secure. If no SSH source shows up, add a journal source in /etc/crowdsec/acquis.d/ssh-journal.yaml:
source: journalctl
journalctl_filter:
- "_SYSTEMD_UNIT=ssh.service"
labels:
type: syslogUse sshd.service as the unit name on Rocky and AlmaLinux. Restart with sudo systemctl restart crowdsec and check the metrics again after a few login attempts.
How do I add Nginx and other services?
Install the collection for the service and point the engine at its logs:
sudo cscli collections install crowdsecurity/nginx
sudo cscli collections install crowdsecurity/base-http-scenariosCreate /etc/crowdsec/acquis.d/nginx.yaml:
filenames:
- /var/log/nginx/access.log
- /var/log/nginx/error.log
labels:
type: nginxsudo systemctl reload crowdsec
sudo cscli metrics show acquisitionCollections exist for many common services, including Postfix, Dovecot and WordPress. Search with sudo cscli collections list -a | grep -i postfix. See the Nginx guide for log locations if you changed them.
How do I test that a ban really blocks traffic?
Create a short manual decision for a documentation address and look for it in the firewall:
sudo cscli decisions add --ip 192.0.2.55 --duration 5m --reason "bouncer test"
sudo cscli decisions list
sudo nft list ruleset | grep -c 192.0.2.55
sudo cscli decisions delete --ip 192.0.2.55The count should be at least 1 a few seconds after the decision. Real detections appear in sudo cscli alerts list, and sudo cscli alerts inspect -d <id> shows the log lines that triggered one.
What if port 8080 is already in use?
The local API binds 127.0.0.1:8080, which often collides with application servers. Move it to a free port in three places, then restart both services:
sudo nano /etc/crowdsec/config.yaml
# api.server.listen_uri: 127.0.0.1:8085
sudo nano /etc/crowdsec/local_api_credentials.yaml
# url: http://127.0.0.1:8085
sudo nano /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
# api_url: http://127.0.0.1:8085/
sudo systemctl restart crowdsec crowdsec-firewall-bouncerCheck with sudo ss -tlnp | grep crowdsec. The Prometheus metrics endpoint on port 6060 is also local only and can stay as it is.
How do I keep CrowdSec up to date?
Package updates arrive with your normal system updates. Hub content (parsers and scenarios) updates separately:
sudo cscli hub update
sudo cscli hub upgrade
sudo systemctl reload crowdsecA weekly timer or cron job for those commands is enough; see cron jobs and timers. If the bouncer ever misbehaves, sudo systemctl stop crowdsec-firewall-bouncer stops enforcement while the agent keeps detecting, and sudo nft list tables confirms the crowdsec tables are gone.
Questions about CrowdSec intrusion prevention
Does CrowdSec send my logs anywhere?
No. Logs are parsed locally. What leaves the server, when community sharing is on, is the address that triggered a scenario, the scenario name and a timestamp. You can turn sharing off in /etc/crowdsec/config.yaml.
How much memory does it use?
The agent and bouncer together are light enough for a 1 GB server with a few log sources. Very busy web logs raise CPU use during parsing.
Can I use it with UFW or firewalld?
Yes. The nftables bouncer keeps its own tables, which run alongside UFW or firewalld rules without editing them.
Do I need the online console?
No. Everything in this guide works with cscli alone. The console is an optional web view of alerts across several servers.
How long does a ban last?
Default decisions last four hours. Profiles in /etc/crowdsec/profiles.yaml control the duration and can raise it for repeat offenders.
More in Security
- UFW firewall on Ubuntu and Debian
- firewalld on Rocky Linux and AlmaLinux
- iptables rules that survive a reboot
- Block brute force logins with fail2ban
- Two-factor SSH logins with TOTP
- Disable or restrict root login
- Alerts for every SSH login
- Advanced OpenSSH settings
- Publish SSH host keys in DNS (SSHFP)
- Audit open ports with nmap
- File integrity checks with AIDE and Tripwire
- CSF firewall (ConfigServer Security)
- First security steps on Rocky and Alma
- Free TLS certificates with Certbot
- Self-signed certificates and a private CA
- Rate and connection limits in Nginx
- Wazuh security monitoring
- Kernel and sysctl hardening