Aller au contenu

Crowdsec

De Banane Atomic

CLI

cscli metrics         # Stats : parsers, scénarios, bouncers
cscli alerts list     # Lister les alertes récentes
cscli decisions list  # Lister toutes les décisions actives

Installation

Extracted commands from the installation script https://install.crowdsec.net
ai apt-transport-https

# import packagecloud gpg key
curl -fsSL https://packagecloud.io/crowdsec/crowdsec/gpgkey | gpg --dearmor | sudo tee /etc/apt/keyrings/crowdsec_crowdsec-archive-keyring.gpg > /dev/null

# add the /etc/apt/sources.list.d/crowdsec_crowdsec.list file

sudo apt-get update
ai crowdsec

# once running, install the iptables bouncer
ai crowdsec-firewall-bouncer-iptables

# status
sc-status crowdsec
sc-status crowdsec-firewall-bouncer-iptables
sudo cscli collections list
sudo cscli decisions list
sudo cscli metrics
/etc/apt/sources.list.d/crowdsec_crowdsec.list
deb [signed-by=/etc/apt/keyrings/crowdsec_crowdsec-archive-keyring.gpg] https://packagecloud.io/crowdsec/crowdsec/any/ any main
deb-src [signed-by=/etc/apt/keyrings/crowdsec_crowdsec-archive-keyring.gpg] https://packagecloud.io/crowdsec/crowdsec/any/ any main

Not attempting to start crowdsec, port 8080 is already used

/etc/crowdsec/config.yaml
api:
  server:
    listen_uri: 127.0.0.1:8081
/etc/crowdsec/local_api_credentials.yaml
url: http://127.0.0.1:8081
systemctl start crowdsec
systemctl status crowdsec

Fail2ban

sc-stop fail2ban
sc-disable fail2ban

Enroll your instance on CrowdSec console

sudo cscli console enroll <token>
sc-restart crowdsec

sudo cscli console status

# if not enabled
sudo cscli console enable console_management
sc-restart crowdsec

# watch the alerts
sudo cscli alerts list

Update

/etc/cron.d/crowdsec-hub-update
# Tous les lundis à 4h00 du matin
0 4 * * 1 root cscli hub update && cscli hub upgrade && systemctl reload crowdsec