25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

How to use Fail2ban to avoid WordPress login attacks

by | Apr 28, 2020

Configuring Fail2ban to monitor WordPress login is an effective way to prevent brute-force attacks on your website.

Fail2ban constantly monitors the server logs and bans IP addresses that show malicious behavior.

At Bobcares, we use fail2ban as a part of our brute-force attack mitigation steps in our Server Management Services.

To know how we do this, read on.

Security threats in WordPress websites

WordPress is a very popular open-source Content Management System, which makes it equally vulnerable to brute-force attacks.

So, what exactly is a brute-force attack?

It is the simplest method to gain access to a site or a server. Usually, attackers run automated scripts that try thousands of username and password combinations, again and again, until it gets in.

Such attacks often eat up lot of server resources and prevent legitimate users from accessing web and mail services. And in case of these attacks lead to outbound spam, IP blacklisting, and other issues.

If a website is attacked by someone, normally a user would block their IP address in the firewall.

However, it’s quite difficult to do this in a brute-force attack, because the user will have to block a large number of IP address, making this practically impossible.

So the best solution would be to have an automated blocking system for the server, that blocks malicious IP addresses.

This is where Fail2ban comes in. We install Fail2ban and integrate it with WordPress to block login attempts.

 

How Fail2Ban prevents WordPress brute-force attack?

Fail2Ban is a software framework for intrusion prevention. It monitors log files for events, such as too many login efforts, and create firewall rules to ban the particular IP addresses.

Hence we install it in our servers and add WP fail2ban plugin to the WordPress. Let’s see how to install the WordPress fail2ban plugin.

  • Initially login to the WordPress site with admin login and access the Dashboard.
  • Next select Plugins from the left panel, this opens a new window.
  • Select the Add New option, to add a new plugin.
  • Search for WP fail2ban in the search bar, which lists the plugin. Click on the Install Now button.

Fail2ban WordPress login

  • Later Activate the plugin from the plugin installer.

Once the plugin is installed, we configure fail2ban. Let’s see how we do it.

 

How to configure Fail2ban to prevent WordPress login attacks?

Basically, here we create rules for blocking IP addresses, that try to login to WordPress with wrong passwords multiple times.

And for doing this we edit the fail2ban local configuration file, that is, /etc/fail2ban/jail.local

[apache-wp-login]
enabled = true
port = http,https
action = iptables[name=WP, port=http, protocol=tcp]
filter = apache-wp-login
logpath = /var/log/apache2/*error.log
maxretry = 3
bantime = 300
ignoreip = 

Later we save and close this file.

Then we create another file, /etc/fail2ban/filter.d/apache-wp-login.conf. To this file, we add the following,

[Definition]
failregex = .*] "POST /wp-login.php
ignoreregex =

Finally, we save and close this file and restart fail2ban using the command,

systemctl restart fail2ban

Thus the configuration is complete.

 

[Need assistance in configuring fail2ban? – We are available 24×7.]

 

Conclusion

In short, to prevent the WordPress brute-force attack, we use fail2ban software which works by continuously monitoring log files and banning IP addresses. Today’s we saw how our Support Engineers configured this.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

3 Comments

  1. debianick

    Thanks, i was looking for this. Im installing it. Hope it works.

    Reply
  2. realtebo

    Actually fail2ban crashes telling us that host group is missing.

    Reply
    • Hiba Razak

      Hi,
      Please contact our support through live chat(click on the icon at right-bottom).

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF