This article is based on a post from the Proxmox forum:
https://forum.proxmox.com/threads/pmg-7-debian-11-with-fail2ban.96109/
Step 1: Update the list of available packages & install the Fail2ban package
apt-get update
apt-get install fail2ban
Step 2: Edit the Fail2ban settings
nano /etc/fail2ban/jail.d/pmg-web-auth.conf
[pmg-web-auth]
enabled = true
port = 8006
filter = pmg-web-auth
logpath = /var/log/daemon.log
maxretry = 5
# 1 hour
bantime = 3600
Step 3: Edit the Fail2ban filter. The filter is the updated one and has slightly different from the original post
nano /etc/fail2ban/filter.d/pmg-web-auth.conf
[Definition]
failregex = pvedaemon\[.*authentication failure; rhost=<HOST> user=.* msg=.*
ignoreregex =
Step 4: Restart the Fail2ban service using the new settings
systemctl restart fail2ban
You can check the Fail2ban’s jail status with this command
fail2ban-client status pmg-web-auth