CrowdSec

Linux
Проверяем не установлен ли Fail2ban:
systemctl status fail2ban.service
Если есть, то отключаем:
systemctl stop fail2ban && systemctl disable fail2ban
Скачиваем и запускаем скрипт:
apt update && apt install curl -y && curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.deb.sh | bash && apt update 

Ставим CrowdSec и вышибалу. Я также ставлю для Nginx. Удалить если не нужен.

apt install -y crowdsec crowdsec-firewall-bouncer-nftables crowdsec-nginx-bouncer

Запускаем настройку:

/usr/share/crowdsec/wizard.sh -c

В файле /etc/crowdsec/notifications/http.yaml производим следующие замены:

  • Название хоста - Hostname
  • ID-чата Телеграм
  • TELEGRAM_API_KEY
nano /etc/crowdsec/notifications/http.yaml

Настроим адреса и сети, не подлежащие блокировке, т.е. белый список:

nano /etc/crowdsec/parsers/s02-enrich/whitelists.yaml

Производим замену в файле /etc/crowdsec/profiles.yaml duration: 2400h
Также раскомментируем строки notification и - http_default для уведомлений в телегу.

nano /etc/crowdsec/profiles.yaml

Далее:

sed -i 's/leakspeed: "10s"/leakspeed: "3600s"/' /etc/crowdsec/scenarios/ssh-bf.yaml && \
sed -i 's/leakspeed: 10s/leakspeed: 3600s/' /etc/crowdsec/scenarios/ssh-bf.yaml && \
sed -i 's/leakspeed: "60s"/leakspeed: "3600s"/' /etc/crowdsec/scenarios/ssh-slow-bf.yaml && \
sed -i 's/leakspeed: 60s/leakspeed: 3600s/' /etc/crowdsec/scenarios/ssh-slow-bf.yaml && \
sed -i 's/online_client/#online_client/' /etc/crowdsec/config.yaml && \
sed -i 's/credentials_path: \/etc\/crowdsec\/online/#credentials_path: \/etc\/crowdsec\/online/' /etc/crowdsec/config.yaml

Перезапускаем службы:

systemctl restart crowdsec crowdsec-firewall-bouncer

Если crowdsec-firewall-bouncer вываливается с ошибой API, то:

cscli bouncers add crowdsec-firewall-bouncer

Копируем полученный API в файл:

nano /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml

Перезапускаем сервис:

systemctl restart crowdsec-firewall-bouncer

Для полного удаления из системы запускаем следующую команду:

apt-get -y autoremove crowdsec crowdsec-firewall-bouncer-nftables && \
apt-get -y purge crowdsec crowdsec-firewall-bouncer-nftables && \
apt-get -y autoremove --purge crowdsec crowdsec-firewall-bouncer-nftables
Proxmox VE 8.x - Debian 12
Проверяем не установлен ли Fail2ban:
systemctl status fail2ban.service
Если есть, то отключаем:
systemctl stop fail2ban && systemctl disable fail2ban
Скачиваем и запускаем скрипт:
apt update && sudo apt dist-upgrade -y && \
apt install rsyslog curl gnupg apt-transport-https nano debian-archive-keyring -y && \
mkdir -p /etc/apt/keyrings/ && \
curl -fsSL https://packagecloud.io/crowdsec/crowdsec/gpgkey | gpg --dearmor > ~/crowdsec_crowdsec-archive-keyring.gpg && \
mv ~/crowdsec_crowdsec-archive-keyring.gpg /etc/apt/keyrings/ && \
apt update && nano /etc/apt/sources.list.d/crowdsec_crowdsec.list 

В открытый файл добавляем репозитории:

deb [signed-by=/etc/apt/keyrings/crowdsec_crowdsec-archive-keyring.gpg] https://packagecloud.io/crowdsec/crowdsec/debian/ bookworm main
deb-src [signed-by=/etc/apt/keyrings/crowdsec_crowdsec-archive-keyring.gpg] https://packagecloud.io/crowdsec/crowdsec/debian/ bookworm main

Установка:

apt update && apt install -y crowdsec crowdsec-firewall-bouncer-iptables

Запускаем настройку:

/usr/share/crowdsec/wizard.sh -c

Выбираю следующие пункты:

[*] crowdsecurity/base-http-scenarios
[*] crowdsecurity/http-cve
[*] crowdsecurity/http-dos
[*] crowdsecurity/linux
[*] crowdsecurity/sshd
[*] crowdsecurity/sshd-impossible-travel
[*] fulljackz/proxmox

В файле /etc/crowdsec/notifications/http.yaml производим следующие замены:

  • Название хоста - Hostname
  • ID-чата Телеграм
  • TELEGRAM_API_KEY
nano /etc/crowdsec/notifications/http.yaml

Настроим адреса и сети, не подлежащие блокировке, т.е. белый список:

rm -f /etc/crowdsec/parsers/s02-enrich/whitelists.yaml && \
nano /etc/crowdsec/parsers/s02-enrich/whitelists.yaml
name: crowdsecurity/whitelists
description: "Whitelist events from private ipv4 addresses"
whitelist:
  reason: "private ipv4/ipv6 ip/ranges"
  ip:
    - "127.0.0.1"
    - "::1"
  cidr:
#    - "192.168.0.0/16"
    - "10.0.0.0/8"
#    - "172.16.0.0/12"

Производим замену в файле /etc/crowdsec/profiles.yaml duration: 2400h
Также раскомментируем строки notification и - http_default для уведомлений в телегу.

nano /etc/crowdsec/profiles.yaml

Далее:

sed -i 's/credentials_path: \/etc\/crowdsec\/online/#credentials_path: \/etc\/crowdsec\/online/' /etc/crowdsec/config.yaml

Перезапускаем службы:

systemctl restart crowdsec crowdsec-firewall-bouncer

Если crowdsec-firewall-bouncer вываливается с ошибой API, то:

cscli bouncers add crowdsec-firewall-bouncer

Копируем полученный API в файл:

nano /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml

Перезапускаем сервис:

systemctl restart crowdsec-firewall-bouncer

Для полного удаления из системы запускаем следующую команду:

apt-get -y autoremove crowdsec crowdsec-firewall-bouncer-iptables && \
apt-get -y purge crowdsec crowdsec-firewall-bouncer-iptables && \
apt-get -y autoremove --purge crowdsec crowdsec-firewall-bouncer-iptables

Fuse

Адрес электронной почты защищен от спам-ботов. Для просмотра адреса в браузере должен быть включен Javascript.