{"id":1883,"date":"2026-09-05T09:36:32","date_gmt":"2026-09-05T04:06:32","guid":{"rendered":"https:\/\/cpanelfree.com\/blog\/how-to-setup-crowdsec-intrusion-prevention-linux-vps\/"},"modified":"2026-09-05T12:59:07","modified_gmt":"2026-09-05T07:29:07","slug":"how-to-setup-crowdsec-intrusion-prevention-linux-vps","status":"publish","type":"post","link":"https:\/\/cpanelfree.com\/blog\/how-to-setup-crowdsec-intrusion-prevention-linux-vps\/","title":{"rendered":"How to Set Up CrowdSec Collaborative Intrusion Prevention on Ubuntu Linux VPS"},"content":{"rendered":"<h2>Why CrowdSec Is the Next-Generation Evolution of Fail2ban<\/h2>\n<p>For over fifteen years, <strong>Fail2ban<\/strong> has been the standard tool for blocking brute-force attacks on Linux servers. While effective, Fail2ban operates as an isolated island: it only reacts after an attacker targets your specific server, relies on brittle regex expressions, and provides no collective threat intelligence from attacks occurring across the wider internet.<\/p>\n<p><strong>CrowdSec<\/strong> is an open-source, collaborative intrusion prevention system (IPS) written in Go. Operating like a decentralized crowd-sourced cyber defense grid, CrowdSec analyzes system and web server logs using structured YAML behavioral scenarios. When an aggressive botnet or vulnerability scanner attacks any CrowdSec user in the world, that malicious IP address is verified by consensus algorithms and instantly distributed to all CrowdSec nodes globally\u2014blocking attackers before they ever reach your server.<\/p>\n<p>In this cybersecurity tutorial, we will configure CrowdSec on Ubuntu 24.04\/22.04 LTS, install firewall remediation bouncers (NFTables\/IPTables), configure Nginx web attack detection, and connect to the CrowdSec Console dashboard.<\/p>\n<h2>Step 1: Adding CrowdSec Package Repository<\/h2>\n<p>Install CrowdSec from the official signed package repository:<\/p>\n<pre><code># Install prerequisites and download repository script\nsudo apt update &amp;&amp; sudo apt install -y curl apt-transport-https\ncurl -s https:\/\/packagecloud.io\/install\/repositories\/crowdsecurity\/crowdsec\/script.deb.sh | sudo bash\n\n# Install CrowdSec Security Engine\nsudo apt update &amp;&amp; sudo apt install -y crowdsec\n\n# Confirm active status\nsudo systemctl status crowdsec --no-pager<\/code><\/pre>\n<h2>Step 2: Installing Remediation Firewall Bouncer<\/h2>\n<p>The CrowdSec engine detects attacks; the <strong>Bouncer<\/strong> executes active blocking at the Linux kernel firewall layer:<\/p>\n<pre><code># Install the official NFTables\/IPTables firewall bouncer\nsudo apt install -y crowdsec-firewall-bouncer-iptables\n\n# Verify bouncer registration\nsudo cscli bouncers list<\/code><\/pre>\n<h2>Step 3: Installing Nginx &amp; Web Attack Collections<\/h2>\n<p>Protect your web applications from SQL injection, path traversal, WordPress brute force, and aggressive crawler scrapers by installing Hub collections via the <code>cscli<\/code> CLI:<\/p>\n<pre><code># Install Nginx log parser and scenario collections\nsudo cscli collections install crowdsecurity\/nginx\nsudo cscli collections install crowdsecurity\/http-cve\nsudo cscli collections install crowdsecurity\/base-http-scenarios\nsudo cscli collections install crowdsecurity\/whitelist-good-actors\n\n# Reload CrowdSec engine to activate collections\nsudo systemctl reload crowdsec<\/code><\/pre>\n<h2>Step 4: Inspecting Real-Time Threat Alerts &amp; Decision Logs<\/h2>\n<p>Inspect active bans, triggered attack scenarios, and community blocklist statistics:<\/p>\n<pre><code># List all currently active IP bans and decisions\nsudo cscli decisions list\n\n# Inspect recent detected security alert incidents\nsudo cscli alerts list\n\n# View active log acquisition streams\nsudo cscli metrics<\/code><\/pre>\n<h2>Step 5: Connecting to CrowdSec Web Console (Optional)<\/h2>\n<p>Enrolling your VPS in the free CrowdSec Console provides visual threat maps, CVE alerts, and centralized multi-server management:<\/p>\n<pre><code># Enroll server with one terminal command\nsudo cscli console enroll &lt;YOUR_CONSOLE_TOKEN&gt;\nsudo systemctl restart crowdsec<\/code><\/pre>\n<h2>CrowdSec vs Traditional Fail2ban Comparison<\/h2>\n<table style=\"width: 100%;border-collapse: collapse;margin: 20px 0;border: 1px solid #334155\">\n<thead>\n<tr style=\"background-color: #0f172a;color: #38bdf8\">\n<th style=\"padding: 12px;border: 1px solid #334155\">Security Capability<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">CrowdSec IPS (Go)<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">Fail2ban (Python)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background-color: #1e293b;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Threat Intelligence<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Global Collaborative Consensus<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">Local server isolation only<\/td>\n<\/tr>\n<tr style=\"background-color: #0f172a;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Preemptive Blocking<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Yes (Known bad IPs blocked before hit)<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">No (Must attack server first)<\/td>\n<\/tr>\n<tr style=\"background-color: #1e293b;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Remediation Actions<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Firewall drop, Captcha, App Ban<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">IPTables port ban only<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Configuring CrowdSec WordPress &amp; Cloudflare Bouncers<\/h2>\n<p>Beyond Linux firewall packet drops, CrowdSec offers application-layer bouncers that integrate directly into WordPress and Cloudflare Edge Firewalls:<\/p>\n<pre><code># Install CrowdSec Cloudflare Bouncer (Blocks bad IPs at Cloudflare Edge before touching VPS)\nsudo apt install -y crowdsec-cloudflare-bouncer\n\n# Configure Cloudflare API Key in \/etc\/crowdsec\/bouncers\/crowdsec-cloudflare-bouncer.yaml\n# Start Cloudflare Bouncer daemon\nsudo systemctl enable --now crowdsec-cloudflare-bouncer<\/code><\/pre>\n<h2>Writing Custom Behavioral Security Scenarios<\/h2>\n<p>Create tailored detection rules for proprietary API endpoints by writing simple YAML rules in <code>\/etc\/crowdsec\/scenarios\/api-flood.yaml<\/code>:<\/p>\n<pre><code>type: leaky\nname: custom\/api-flood\ndescription: \"Detect aggressive API abuse on sensitive endpoints\"\nfilter: \"evt.Meta.service == 'http' &amp;&amp; evt.Parsed.request startsWith '\/api\/v1\/auth'\"\ngroupby: evt.Meta.source_ip\ncapacity: 5\nleakspeed: 2s\nblackhole: 1m\nlabels:\n  type: brute-force\n  remediation: true<\/code><\/pre>\n<h2>CrowdSec Verification &amp; CLI Management<\/h2>\n<ul>\n<li><code>sudo cscli hub list<\/code>: View all installed log parsers, scenarios, and collections.<\/li>\n<li><code>sudo cscli alerts inspect &lt;alert-id&gt;<\/code>: Inspect full forensic attack telemetry.<\/li>\n<\/ul>\n<h2>Setting Up CrowdSec Web Application Firewall (AppSec) Component<\/h2>\n<p>In addition to log parsing, modern CrowdSec includes an embedded Application Security (AppSec) engine that inspects incoming HTTP request bodies in real time to block OWASP Top 10 vulnerabilities (SQLi, XSS, NoSQLi, RCE, and SSTI) before they ever reach your web application backend:<\/p>\n<pre><code># Enable AppSec component in CrowdSec\nsudo cscli collections install crowdsecurity\/appsec-virtual-patching\nsudo cscli collections install crowdsecurity\/appsec-generic-rules\nsudo systemctl reload crowdsec<\/code><\/pre>\n<h2>Automating Threat Reports &amp; Daily Digest Summaries<\/h2>\n<p>Generate automated daily security digests of all blocked IP addresses and attack origins:<\/p>\n<pre><code># Generate daily threat analysis summary\nsudo cscli metrics show --since 24h\n\n# Inspect the top offending Autonomous System Numbers (ASNs) and countries\nsudo cscli alerts list --limit 50<\/code><\/pre>\n<h2>CrowdSec Threat Intelligence Verification &amp; Hub Best Practices<\/h2>\n<ul>\n<li><strong>Keep Scenarios Updated:<\/strong> Schedule daily <code>cscli hub update &amp;&amp; cscli hub upgrade<\/code> cron jobs to receive the latest CVE signatures.<\/li>\n<li><strong>Whitelist Trusted DevOps IPs:<\/strong> Always add your home, office, and VPN IP addresses to <code>\/etc\/crowdsec\/parsers\/s02-enrich\/whitelist.yaml<\/code> to prevent accidental administrative lockouts.<\/li>\n<\/ul>\n<div style=\"background-color: #0f172a;border-left: 4px solid #38bdf8;padding: 18px 24px;margin: 30px 0;border-radius: 8px\">\n<h3 style=\"color: #38bdf8;margin-top: 0\">Recommended Related Technical Guides<\/h3>\n<ul style=\"margin-bottom: 0;color: #cbd5e1\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-secure-linux-vps-fail2ban-ufw-ssh\/\" style=\"color: #38bdf8;text-decoration: underline\">Securing Linux Cloud VPS with UFW &amp; SSH Hardening<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/top-10-essential-linux-terminal-commands-webmasters-2026\/\" style=\"color: #38bdf8;text-decoration: underline\">Top 10 Essential Linux Terminal Commands for Webmasters<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-setup-wireguard-vpn-server-ubuntu-vps\/\" style=\"color: #38bdf8;text-decoration: underline\">Setting Up Encrypted WireGuard VPN on Ubuntu VPS<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);color: #ffffff;padding: 28px;border-radius: 12px;margin: 35px 0;text-align: center\">\n<h3 style=\"color: #ffffff;margin-top: 0;font-size: 22px\">Fortress-Grade Cloud Security with CpanelFree<\/h3>\n<p style=\"color: #e0f2fe;font-size: 15px;max-width: 650px;margin: 0 auto 18px auto\">Shield your applications against cyber threats with enterprise DDoS mitigation, automated firewall bouncers, and 100% free hosting and VPS options.<\/p>\n<p>  <a href=\"https:\/\/cpanelfree.com\/\" style=\"background-color: #ffffff;color: #0284c7;font-weight: 700;padding: 12px 28px;border-radius: 8px;text-decoration: none;display: inline-block\">Deploy Free Secure Hosting Today &rarr;<\/a>\n<\/div>\n<div style=\"border-left: 4px solid #38bdf8;border-radius: 8px;padding: 20px;margin: 30px 0\">\n<h3 style=\"margin-top: 0;color: #38bdf8;font-size: 18px;display: flex;align-items: center\">\n        <span style=\"margin-right: 8px\">\ud83d\udd17<\/span> Recommended Related Technical Guides:<br \/>\n    <\/h3>\n<ul style=\"margin: 10px 0 0 0;padding-left: 20px;line-height: 1.8\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-secure-linux-vps-hardening-guide\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Secure Your Linux VPS: 7 Essential Hardening Steps (2026)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-configure-ufw-firewall-ubuntu\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Configure UFW Firewall on Ubuntu Server (Rules, Ports &amp; Best Practices)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-install-configure-fail2ban-linux\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Install and Configure Fail2ban on Linux (Stop SSH Brute-Force Attacks)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-host-multiple-websites-free-hosting\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Host Multiple Websites on a Single Free Hosting Account<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"color: #10b981;text-decoration: none;font-weight: 600\">Explore $0 Free cPanel Web Hosting Plans (NVMe SSD, AutoSSL)<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);border-radius: 12px;padding: 25px;margin: 30px 0;text-align: center\">\n<h3 style=\"color: #38bdf8;margin-top: 0;font-size: 20px\">Deploy Fast, Reliable Web Hosting on CpanelFree<\/h3>\n<p style=\"color: #94a3b8;font-size: 14px;line-height: 1.6;max-width: 600px;margin: 0 auto 15px\">\n        Get genuine cPanel control, unmetered NVMe SSD storage, and free AutoSSL at $0 cost forever.\n    <\/p>\n<p>    <a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"display: inline-block;background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);color: #ffffff;padding: 10px 22px;border-radius: 6px;text-decoration: none;font-weight: bold;font-size: 14px\">Claim Free Hosting Account<\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Why CrowdSec Is the Next-Generation Evolution of Fail2ban For over fifteen years, Fail2ban has been the standard tool for blocking brute-force attacks on Linux servers. While effective, Fail2ban operates as an isolated island: it only reacts after an attacker targets your specific server, relies on brittle regex expressions, and provides no collective threat intelligence from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2508,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[],"class_list":["post-1883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security"],"_links":{"self":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/comments?post=1883"}],"version-history":[{"count":4,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1883\/revisions"}],"predecessor-version":[{"id":2308,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1883\/revisions\/2308"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media\/2508"}],"wp:attachment":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media?parent=1883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/categories?post=1883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/tags?post=1883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}