Blog / Tutorials / CrowdSec on a VPS: Install and Protect Your Server
(last updated: )

CrowdSec on a VPS: Install and Protect Your Server

CrowdSec reads your server's logs, spots attacks such as SSH brute force, and blocks the offending IPs through a separate component called a bouncer. It also pulls in a community blocklist of addresses other users have reported. You can install it from packages on Ubuntu…

7 min read
CrowdSec reads VPS logs and sends blocking decisions to a firewall bouncer

CrowdSec reads your server’s logs, spots attacks such as SSH brute force, and blocks the offending IPs through a separate component called a bouncer. It also pulls in a community blocklist of addresses other users have reported. You can install it from packages on Ubuntu or run the engine in Docker, and the whole thing needs very little RAM.

What Is CrowdSec?

CrowdSec has four moving parts, and mixing them up is the most common reason an install seems to do nothing.

  • The engine (the security engine, or agent) reads log files and matches them against scenarios, which are YAML rules for attack patterns.
  • The local API (LAPI) stores the decisions the engine makes, such as ‘ban this IP for 4 hours’.
  • Bouncers ask the API for decisions and enforce them, for example by adding firewall rules.
  • The community blocklist adds IPs reported by other CrowdSec users, so your server blocks some attackers before they try anything.

The key point: the engine detects, the bouncer blocks. If you install only the engine, you get alerts and decisions but no blocking. Fail2ban users are sometimes caught out by this, since Fail2ban does both in one tool.

CrowdSec Install on Ubuntu

On Ubuntu 22.04 or 24.04 the install takes about five minutes. Add the CrowdSec repository, install the engine, then install a firewall bouncer. Ubuntu uses nftables by default, so pick the nftables bouncer unless you know your setup uses iptables.

# add the official repository, then install the engine
curl -s https://install.crowdsec.net | sudo sh
sudo apt install crowdsec

# install the firewall bouncer (nftables)
sudo apt install crowdsec-firewall-bouncer-nftables

# check that both are running and talking to each other
sudo systemctl status crowdsec crowdsec-firewall-bouncer
sudo cscli bouncers list
sudo cscli metrics

The installer detects services such as SSH from your log files and enables matching collections on its own. Run sudo cscli collections list afterwards to see what it picked. The bouncer’s config sits in /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml, and the package registers its API key for you.

Expect a quiet first hour. On a public IP, SSH scans often show up within minutes, so after a day sudo cscli alerts list will probably show some entries, and the community blocklist should have loaded on its own. If both lists stay empty after 24 hours, check that the engine is reading the right log: sudo cscli metrics should show parsed lines for auth.log or the journal. Zero parsed lines means a log path problem, not a quiet server.

To test it, add a fake ban for a documentation address and look for it in the decision list: sudo cscli decisions add –ip 203.0.113.50 –duration 10m, then sudo cscli decisions list. Don’t test with your own IP unless you like being locked out.

CrowdSec Docker Setup

If your apps already run in containers, you can run the engine in a container too. The engine reads logs, so it needs read access to the log files or the journal of the host, and the bouncer should run on the host so it can change the host’s firewall.

services:
  crowdsec:
    image: crowdsecurity/crowdsec:latest
    container_name: crowdsec
    restart: unless-stopped
    environment:
      COLLECTIONS: "crowdsecurity/linux crowdsecurity/sshd"
    volumes:
      - ./config:/etc/crowdsec
      - ./data:/var/lib/crowdsec/data
      - ./acquis.yaml:/etc/crowdsec/acquis.yaml:ro
      - /var/log/auth.log:/var/log/auth.log:ro
    ports:
      - "127.0.0.1:8080:8080"   # local API, host only

Pin the image to a version tag once it works, because the latest tag moves. Generate the bouncer’s key with docker exec crowdsec cscli bouncers add host-firewall, put it in the host bouncer’s config along with api_url: http://127.0.0.1:8080, and restart the bouncer. Check docker exec crowdsec cscli metrics to confirm the log lines are being read.

Protect SSH and Web Services with CrowdSec Collections

A collection bundles parsers and scenarios for one service. The Linux and SSH collections cover brute-force attempts on port 22. For web traffic, add the Nginx or Traefik collections and point the engine at the access logs.

  • crowdsecurity/sshd catches repeated failed SSH logins.
  • crowdsecurity/nginx adds web scans and common probing patterns.
  • crowdsecurity/http-cve covers requests that match known exploits.

Keep SSH on key-only login anyway. CrowdSec lowers the noise, but it’s not a replacement for turning off password authentication. Our guides on SSH setup and on hardening a VPS cover that part.

CrowdSec Dashboard and Console

You have two ways to see what CrowdSec is doing. The command line is the quick one: cscli metrics shows what was parsed, cscli decisions list shows active bans, and cscli alerts list shows what triggered them. For a web view, you can enrol the instance in the CrowdSec Console with cscli console enroll and a key from your account.

Older guides show a local dashboard built on Metabase (cscli dashboard setup). That route has been deprecated in recent releases, so check the current CrowdSec docs before following one of those tutorials.

CrowdSec vs Fail2ban

Fail2ban is simple and well known: it tails logs, matches regexes, and bans IPs through firewall actions. CrowdSec does the same job with a different design. Detection and enforcement are split, rules are written as scenarios, and your instance shares signals with the community blocklist.

CrowdSec vs Fail2ban Compared from each project’s public documentation and third-party comparisons, as of December 2026. Defaults can change between releases.
CrowdSecFail2ban
Detection modelScenarios and parsers in YAMLRegex filters in jail files
BlockingSeparate bouncers (nftables, iptables, web servers)Built-in firewall actions
Shared intelligenceCommunity blocklist and optional signal sharingNone
Default ban time (third-party)About 4 hours10 minutes
LanguageGoPython
Setup effortA little more: engine plus bouncerLow: one package and a jail.local

If you already run Fail2ban and it works, there’s no urgent reason to switch. For a new server, or one that sees a lot of scanning, CrowdSec’s blocklist is a real advantage. Don’t run both against the same logs without a reason. Our guides on Fail2ban cover that tool in detail, in case you want to compare before you decide.

Why Run CrowdSec on a Contabo VPS

CrowdSec is light, so any Core VPS handles it with RAM to spare, even next to a few Docker apps. Contabo also offers a free firewall with every VPS and VDS, and the two layers work well together: the provider firewall drops obvious traffic early, and CrowdSec reacts to what shows up in your logs.

Basics first: our VPS security checklist and the guide on UFW.

FAQ: CrowdSec

Is CrowdSec better than Fail2ban?

It depends on what you need. CrowdSec adds a shared community blocklist and a split between detection and enforcement. Fail2ban is simpler and has fewer parts. For a new server that sees a lot of scanning, CrowdSec is usually the stronger option.

Is CrowdSec free?

The open-source security engine and the firewall bouncers are free to use. CrowdSec also offers paid plans for its console and extra blocklists, but the core install in this guide doesn’t need an account to block attackers.

How do I check CrowdSec decisions?

Run sudo cscli decisions list to see active bans and sudo cscli alerts list to see what triggered them. In Docker, prefix the command with docker exec crowdsec. The CrowdSec Console gives the same information in a browser.

Can I run CrowdSec in Docker and still block the host?

Yes. Run the engine in a container and the firewall bouncer on the host, then point the bouncer at the engine’s local API on port 8080 with an API key. The bouncer changes the host’s nftables or iptables rules.

Disclaimer: Product specifications, features, and prices mentioned in this article are subject to change and may vary by region, billing term, and active promotions. Please check each provider’s or brand’s official website for current figures, pricing, and local currency rates.