Web Hosting & VPS Tips

Unleash Your Server Potential with Expert Insights

Hosting provided by: Cloudways
Free to Try! Up to 40% Off!

Category: VPS Setup

Rotate Fail2ban logs on Ubuntu—install with
apt install fail2ban
then edit /etc/logrotate d/fail2ban with
nano /etc/logrotate.d/fail2ban
:
/var/log/fail2ban.log {\n daily\n rotate 7\n compress\n delaycompress\n missingok\n notifempty\n postrotate\n /usr/bin/fail2ban-client reload &> /dev/null\n endscript\n}
Set up an SSH jail in /etc/fail2ban/jail local restart with
systemctl restart fail2ban
and open SSH with
ufw allow 22
Test rotation with
logrotate -f /etc/logrotate.d/fail2ban
—check /var/log/fail2ban log* On Hetzner this keeps MySQL and FTP logs manageable ensuring uptime with clean log files

Back to All Tips