How to Limit Login Attempts in WordPress to Prevent Brute Force Breaches

WordPress is a powerful and widely used content management system, and limiting the number of login attempts is an effective way to prevent brute force breaking attacks. In this article, we will explain in detail how to limit the number of login attempts in WordPress to improve the security of your website.

图片[1]-如何在 WordPress 中限制登录尝试次数以防止暴力破解-光子波动网 | WordPress教程、Elementor教程与故障修复

What is a brute force attack?

A brute force attack is an attack that involves accessing an account by constantly trying various password combinations. Hackers usually use automated tools to try a large number of passwords quickly. If there is no limit on the number of login attempts, hackers can try passwords an unlimited number of times until they find the right combination.

Why do I need to limit the number of login attempts?

Limiting the number of login attempts can significantly reduce the likelihood of a successful brute force attack. By setting a reasonable limit on the number of login attempts, you can prevent hackers from trying a large number of passwords in a short period of time, thus improving the security of your website.

How to Limit Login Attempts in WordPress

There are several ways to implement a limit on the number of login attempts in WordPress. Here are some common methods and recommended plugins:

1. Use the plug-in to limit the number of login attempts

Using plugins is one of the easiest and most effective ways to do this. Here are a few recommended plugins:

Limit Login Attempts ReloadedThis plugin helps you to easily set and manage the limit on the number of login attempts. It offers rich setting options that can be customized according to your needs.

  • Installation steps::

1. In the WordPress dashboard, navigate to "plug-in (software component)"->"Installation of new plug-ins".

2. Search for "Limit Login Attempts Reloaded".

3. Install and activate the plug-in.

    图片[2]-如何在 WordPress 中限制登录尝试次数以防止暴力破解-光子波动网 | WordPress教程、Elementor教程与故障修复

    4. In "set up"->"Limit Login Attempts" to configure the plug-in.

      图片[3]-如何在 WordPress 中限制登录尝试次数以防止暴力破解-光子波动网 | WordPress教程、Elementor教程与故障修复

      Login LockdownThis plugin logs each failed login attempt and locks that IP address for a period of time after a preset number of attempts have been exceeded.

      • Installation steps::
        1. In the WordPress dashboard, navigate to Plugins -> Install New Plugin.
        2. Search for "Login Lockdown".
        3. Install and activate the plugin.
        4. Configure the plugin in "Settings" -> "Login Lockdown".

      WPS Limit LoginThis plugin allows you to limit the number of login attempts and block IP addresses when the limit is exceeded.

      • Installation steps::
        1. In the WordPress dashboard, navigate to Plugins -> Install New Plugin.
        2. Search for "WPS Limit Login".
        3. Install and activate the plugin.
        4. In "set up"->"WPS Limit Login" to configure the plug-in.

      2. Manually add code to limit the number of login attempts

      图片[4]-如何在 WordPress 中限制登录尝试次数以防止暴力破解-光子波动网 | WordPress教程、Elementor教程与故障修复

      If you prefer to do it manually, you can do it by adding a new function to the theme's functions.php file to add code to implement a limit on the number of login attempts. Below is a sample code:

      function custom_login_attempts_limit() {
          if (!session_id()) {
              session_start();
          }
      
          if (isset($_SESSION['login_attempts']) && $_SESSION['login_attempts'] >= 3) {
              $lockout_time = 15 * 60; // 15 minutes
              $current_time = time();
      
              if ($current_time - $_SESSION['last_attempt_time']  sanitize_text_field($_POST['log']),
                      'user_password' => $_POST['pwd'],
                      'remember' => isset($_POST['rememberme']) ? sanitize_text_field($_POST['rememberme']) : false
                  ).
      
                  $user = wp_signon($creds, false );
      
                  if (is_wp_error($user)) {
                      $_SESSION['login_attempts'] = isset($_SESSION['login_attempts']) ? $_SESSION['login_attempts'] + 1 : 1;
                      $_SESSION['last_attempt_time'] = time();
                  } else {
                      $_SESSION['login_attempts'] = 0;
                  }
              }
          }
      }
      add_action('login_init', 'custom_login_attempts_limit');

      Configure reasonable limits on login attempts

      Whether you choose to use a plugin or add code manually, configuring reasonable limits on login attempts is key. Here are some recommended settings:

      • Number of login attempts: Limit the number of login attempts to 3-5 Times.
      • lock time: The lock time is set to 15-30 Minutes.
      • Increase lock time: Gradually increase the lockout time after each lockout.

      Monitor and manage login attempts

      Once a limit on the number of login attempts has been set, regular monitoring and management of these attempts is key to keeping your website secure. Ensure that the plugins used provide logging and notification features so that prompt action can be taken when unusual login activity is detected.

      图片[5]-如何在 WordPress 中限制登录尝试次数以防止暴力破解-光子波动网 | WordPress教程、Elementor教程与故障修复

      reach a verdict

      Limiting the number of login attempts is an effective way to prevent brute force breaking attacks. By using a plugin or adding code manually, you can easily implement this feature and greatly improve the security of your WordPress site.


      Contact Us
      Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
      客服微信
      Customer Service
      Tel: 020-2206-9892
      QQ咨询:1025174874
      (iii) E-mail: [email protected]
      Working hours: Monday to Friday, 9:30-18:30, holidays off
      © Reprint statement
      本文作者:红牛独立站
      THE END
      If you like it, support it.
      kudos0 share (joys, benefits, privileges etc) with others
      commentaries sofa-buying

      Please log in to post a comment

        No comments