Я пытаюсь реализовать fail2ban
на сервере Ubuntu 12.04 x64. Я сделал следующее:
apt-get install fail2ban
Сделанный копией jail.conf
в /etc/fail2ban/jail.conf.local
вот выборка:
[DEFAULT]
# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8
bantime = 600
maxretry = 3
[ssh]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
bantime = 600
Затем я работал service fail2ban restart
и я действительно вижу, что он работает. Теперь я пытаюсь войти в систему как пользователь (корень, случайный пользователь, и т.д.) многократно подряд, и он не блокирует мой IP-адрес. Я имею iptables
установленный и это работающий с правилами у меня есть установка, и у меня действительно есть a INPUT
объедините в цепочку на месте, конечно.
Когда я кошка /var/log/auth.log
это - то, что я вижу
Oct 26 08:55:21 prod sshd[10935]: reverse mapping checking getaddrinfo for firewall.jaincpa.com [75.89.97.25] failed - POSSIBLE BREAK-IN ATTEMPT!
Oct 26 08:55:23 prod sshd[10935]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=75.89.97.25 user=root
Oct 26 08:55:25 prod sshd[10935]: Failed password for root from 75.89.97.25 port 61449 ssh2
Oct 26 08:55:32 sshd[10935]: last message repeated 2 times
Oct 26 08:55:32 prod sshd[10935]: Connection closed by 75.89.97.25 [preauth]
Oct 26 08:55:32 prod sshd[10935]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=75.89.97.25 user=root
Oct 26 08:55:34 prod sshd[10944]: reverse mapping checking getaddrinfo for firewall.jaincpa.com [75.89.97.25] failed - POSSIBLE BREAK-IN ATTEMPT!
Oct 26 08:55:35 prod sshd[10944]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=75.89.97.25 user=root
Oct 26 08:55:37 prod sshd[10944]: Failed password for root from 75.89.97.25 port 61452 ssh2
Oct 26 08:55:44 sshd[10944]: last message repeated 2 times
Oct 26 08:55:44 prod sshd[10944]: Connection closed by 75.89.97.25 [preauth]
Oct 26 08:55:44 prod sshd[10944]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=75.89.97.25 user=root
Oct 26 08:55:47 prod sshd[10951]: reverse mapping checking getaddrinfo for firewall.jaincpa.com [75.89.97.25] failed - POSSIBLE BREAK-IN ATTEMPT!
Oct 26 08:55:51 prod sshd[10951]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=75.89.97.25 user=root
Oct 26 08:55:52 prod sshd[10951]: Failed password for root from 75.89.97.25 port 61455 ssh2
Oct 26 08:56:00 sshd[10951]: last message repeated 2 times
Oct 26 08:56:00 prod sshd[10951]: Connection closed by 75.89.97.25 [preauth]
Oct 26 08:56:00 prod sshd[10951]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=75.89.97.25 user=root
Oct 26 08:56:13 prod sshd[10971]: reverse mapping checking getaddrinfo for firewall.jaincpa.com [75.89.97.25] failed - POSSIBLE BREAK-IN ATTEMPT!
Oct 26 08:56:15 prod sshd[10971]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=75.89.97.25 user=root
Oct 26 08:56:16 prod sshd[10971]: Failed password for root from 75.89.97.25 port 61459 ssh2
Oct 26 08:56:22 sshd[10971]: last message repeated 2 times
Oct 26 08:56:22 prod sshd[10971]: Connection closed by 75.89.97.25 [preauth]
Oct 26 08:56:22 prod sshd[10971]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=75.89.97.25 user=root
Oct 26 08:57:18 prod sshd[11002]: Connection closed by 50.116.16.93 [preauth]
Oct 26 09:00:01 prod CRON[11099]: pam_unix(cron:session): session opened for user deploy by (uid=0)
Oct 26 09:00:02 prod CRON[11099]: pam_unix(cron:session): session closed for user deploy
Oct 26 09:02:18 prod sshd[11186]: Connection closed by 50.116.16.93 [preauth]
root@prod:/etc/fail2ban#
Таким образом, похоже, что я прохожу проверку подлинности с PAM
через sshd
но fail2ban
не блокирует мой IP-адрес, и я могу все еще делать попытку входа в систему и войти в систему при предоставлении надлежащих учетных данных.
Я хотел бы получить эту работу, поскольку я видел много атак перебором моего сервера в последнее время. Любая справка значительно ценилась бы.
Похоже, мне нужно было указать серверную часть, чтобы заставить это работать. По умолчанию использовался гамин
, который не работал. Я изменил конфигурацию на backend = polling
, и fail2ban работает правильно. Не получал уведомлений по электронной почте о блокировке, но я близок к тому, чтобы это выяснить.