It's unbelievable Plesk still doesn't have a mechanism to protect itself from brute-force login attacks!
While we are waiting for authors to make it available as an option in the Admin panel, here's how I do it:
Have a look at database "psa", table "log_actions".
Plesk logs failed logins here, unfortunately without the username entered. Nevertheless, we can see the IP address in this table.
The field "action_id" has the value of 125 for failed logins. The field "ip_address" holds the IP address..
So, we can create the script, run from cron every 5 minutes:
Code:
mysql -NBe "SELECT CONCAT('host=',ip_address),date FROM log_actions WHERE action_id=125 AND UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(date) < 300" psa | while read line
do
logger -p auth.warn -t PLESK-LOGIN-FAILED $line
done
OK, fine, now we can configure fail2ban to detect this. First, create the new filter rule, for example: /etc/fail2ban/filter.d/plesk-login.conf :
Code:
[Definition]
failregex = PLESK-LOGIN-FAILED: host=<HOST>
Finally, create the appropriate fail2ban jail in /etc/fail2ban/jail.local :
Code:
[plesk-login]
enabled = true
port = 8443
action = iptables-multiport[name=plesk-login, port=8443, protocol=tcp] # ... etc (chnage it to suit your needs)
filter = plesk-login
logpath = /var/log/auth.log
findtime = 300
maxretry = 5
bantime = 86400
Restart fail2ban service.
Et voila...
