Question

Fail2Ban Not Automatically Ban IP After Several Failed Login Attempts

I have set up a droplet running on Ubuntu 18.04. Everything including my websites on WordPress is working perfectly. But as I read on many blogs regarding hardening server security, then, I tried to install Fail2Ban. Installation is successful and jail is created. But when I tried to enter the wrong password, it does not ban my IP. I have tried all tutorials below but still cannot automatically ban my IP on failed SSH login attempts. Is there somewhere I missed which makes me unable to automatically ban my IP?

Tutorial followed. https://www.digitalocean.com/community/tutorials/how-to-protect-ssh-with-fail2ban-on-ubuntu-14-04 https://www.digitalocean.com/community/tutorials/how-to-protect-an-apache-server-with-fail2ban-on-ubuntu-14-04 https://www.digitalocean.com/community/tutorials/how-to-protect-an-apache-server-with-fail2ban-on-ubuntu-14-04

Below is additional info if it helps. Webserver: Openlitespeed. Firewall: DigitalOcean Firewall & UFW. DNS: Cloudflare. SSH Connection: Putty. SSH Login: Using key pairs. SSH Password login: Disabled. Root login: Disabled.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
October 24, 2020
Accepted Answer

Hi there @shahahmadyusof,

What I could suggest is to make sure you restart fail2ban after making any configuration changes

Also make sure findtime isn’t set too low.

Another thing that I could suggest is to try and trigger a few unsuccessful SSH attempts from a different IP besides your main one.

Let me know how it goes! Regards, Bobby

alexdo
Site Moderator
Site Moderator badge
November 19, 2022

Hello there,

If you want further integration between WordPress and Fail2ban you’ll need to install the Fail2ban plugin

https://wordpress.org/plugins/wp-fail2ban/

Regards

alexdo
Site Moderator
Site Moderator badge
November 19, 2022

Hello there,

You can install CSF in order to manage the Firewall configuration of the droplet. CSF is extremely easy to use and configure.

To block an IP address or range just use:

  1. csf -d IPaddress

We also have a tutorial which you can check here:

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-config-server-firewall-csf-on-ubuntu

Regards

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.