Harden WordPress: hardening settings, firewall and two-factor sign-in
Last updated
Hardening means changing settings so a site is harder to break into: closing doors attackers commonly use, hiding information that helps them and making logins tougher. None of it replaces keeping software up to date, but together these settings stop a large share of everyday attacks.
MaintainHQ sets these on your WordPress sites remotely through the MaintainHQ plugin, so you do not have to edit files by hand. This guide covers the WP Hardening tab, the firewall, two-factor sign-in and the emergency reset for administrators who are locked out.
The WP Hardening tab
Open Security in the left-hand menu and choose WP Hardening, then pick a site under Select a site to harden. (On a site’s own page, open Security and the site is already chosen.) MaintainHQ reads the site’s current settings; press Refresh to read them again.
At the top, a score shows how many hardening controls are on, as a percentage: Excellent, Moderate or Needs Work. Apply Recommended turns on the recommended settings that are not already on, in one go, and reports how many it applied. If the site’s plugin does not support a setting yet, it says so.
If the site has an SSL certificate, a card shows when it expires and how many days are left.
Login & Access
| Setting | What it does |
|---|---|
| Custom Admin Login URL | Moves the login page to an address you choose, such as /my-secret-login. When active, /wp-admin and /wp-login.php return a “not found” page. Press Save to apply |
| Block /wp-admin & /wp-login.php | Returns “not found” for the default admin addresses when a custom login address is set, so nobody can bypass it |
| Limit Login Attempts | After this many failed tries (the default is 5), the visitor is locked out for this many minutes (the default is 30). Press the save icon to apply |
| Force Strong Passwords | Requires every user to set a strong password |
| Disable XML-RPC | Turns off XML-RPC, an old remote access feature often used in password-guessing and flooding attacks |
File & System Protection, API and headers
| Setting | What it does |
|---|---|
| Disable File Editor | Removes the theme and plugin code editor from wp-admin, so a stolen admin login cannot be used to edit code |
| Hide WP Version | Removes the WordPress version number from the page source and feeds |
| Disable Directory Browsing | Stops visitors seeing a list of the files in a folder |
| Disable PHP in Uploads | Stops PHP files in the uploads folder from running, a common way to plant a backdoor (hidden access for an attacker) |
| Restrict REST API | Only logged-in users can use the WordPress REST API, a way for programs to read and change the site |
| X-Frame-Options | Stops other sites showing yours inside a frame, which prevents clickjacking |
| HSTS (Strict Transport Security) | Tells browsers to always use the secure HTTPS address |
| X-Content-Type-Options | Stops browsers guessing file types, which blocks some attacks |
| Core, Plugin and Theme Auto-Updates | Lets WordPress install updates for core, all plugins or all themes by itself |
Disable Directory Browsing and Disable PHP in Uploads work through a server file called .htaccess. On servers that ignore it (nginx), the switch is unavailable and MaintainHQ shows the line your host needs to add instead.
The firewall
The firewall checks requests to your site and blocks common attacks before WordPress handles them. Turn it on per site in the Firewall card on the Overview tab of the Security page, or on a site’s Firewall tab.
With it on, the MaintainHQ plugin (3.7.0 or later) blocks SQL injection, cross-site scripting (XSS) and path traversal attempts, and probes for sensitive files such as wp-config.php. It also locks an IP address out of logging in for 15 minutes after 20 failed logins. Administrators are never blocked.
Blocked requests appear after the site’s next hourly check-in. The firewall cards show Blocked, Allowed, Unique IPs and the Top Rule, and Recent Firewall Activity lists individual requests.
Two-factor sign-in for WordPress users
Two-factor sign-in means WordPress logins ask for a code from an authenticator app on the user’s phone as well as the password, so a stolen password is not enough. The check happens on the site itself, so sign-in keeps working even if MaintainHQ is unreachable. It needs the MaintainHQ plugin 3.23.0 or later. You find the Two-factor sign-in card on the WP Hardening tab.
| Setting | Choices |
|---|---|
| Two-factor sign-in | Off; Optional: users choose; Required for chosen roles |
| Time to set it up | Straight away, or 3, 7, 14 or 30 days (when required) |
| Remember a device | Never: ask every time, or for 7 or 30 days |
| Required for | The roles that must use it, such as Administrator and Editor |
Press Save. Each user then sets it up on their own WordPress profile page. Until their time runs out they see a reminder; after that they can only reach their profile page until they set it up. The table shows each user’s status and warns when someone has fewer than 3 backup codes left.
If someone loses their phone, press Reset next to them. Their app and backup codes stop working and they sign in with just their password until they set it up again. Only do this once you are sure it is really them asking.
Emergency reset for a locked-out administrator
On a site’s Security tab, the Emergency reset card helps an administrator who cannot get into wp-admin. It needs two-factor authentication on your own MaintainHQ account (set it up under Profile).
- Press Start emergency reset.
- Choose the administrator who is locked out and press Continue.
- Enter the current code from your authenticator app (or a backup code) and press Reset and make link.
- Copy the single-use sign-in link and give it only to that person.
MaintainHQ signs them out everywhere, and opening the link replaces their password so they choose a new one straight away. The link works once and expires; it is not shown again. The account owner is emailed every time.