Two-factor authentication: how to enable it in cPanel and WordPress
Two-factor authentication (2FA) requires, in addition to your password, a six-digit code generated by your phone that changes every 30 seconds. Anyone who discovers your password can’t log in without that code. For a website, it’s worth enabling it in two places: in cPanel, which gives access to files, email, and databases, and in WordPress, which gives access to the content and plugins.
This article shows how to enable it in both. You’ll need an authenticator app on your phone. Any app that follows the TOTP standard works, such as Google Authenticator, Microsoft Authenticator, Authy, or 2FAS. We don’t recommend any particular one.
Before you start
- Install the authenticator app on your phone and make sure the date and time on the device are set to “automatic”. A code with the wrong time will be rejected.
- Have your current cPanel and WordPress passwords at hand.
- If more than one person uses the same login, agree on this beforehand: with two-factor authentication enabled, only the person with the registered phone can log in. Ideally, each person should have their own user (see site passwords and access).
Enable it in cPanel
The exact menu names can vary a little depending on the cPanel version and theme of your host.
- Log in to cPanel.
- In the Security section, open Two-Factor Authentication.
- Click Set Up Two-Factor Authentication.
- On your phone, open the authenticator app, choose to add an account, and scan the QR code shown on the screen.
- The app will show a six-digit code. Type it into the confirmation field in cPanel.
- Click Generate or Configure (the button label varies) and wait for the message confirming that two-factor authentication has been enabled.
From the next login on, cPanel asks for your username, password, and the code from the app.
If the Two-Factor Authentication option doesn’t appear in your cPanel, your host may have disabled it. In that case, ask your host’s support whether it can be enabled for your account.
What to do if you lose your phone
cPanel usually doesn’t provide recovery codes. If you lose the device or delete the app, you can’t generate the code. Only your host’s support can disable the verification, after confirming that the account is yours. For that reason:
- write down, in a safe place, the setup key that cPanel shows next to the QR code, in case you need to add the app to a new phone;
- use an authenticator app that allows backup or transfer to another device, and check how that works before you need it.
Enable it in WordPress
WordPress doesn’t include two-factor authentication by default, so you need to install a plugin. There are several options, such as Two Factor, WP 2FA, and the login module of Wordfence. Choose one that is actively maintained: check the official plugin directory for the date of the last update and its compatibility with your WordPress version. The steps below apply to most of them, although menu names differ from one plugin to another.
- In the WordPress dashboard, go to Plugins > Add New.
- Search for the plugin you chose, click Install Now, and then Activate. See the step-by-step guide in how to install a plugin in WordPress.
- Open your profile under Users > Profile, or the settings screen the plugin creates.
- In the two-factor authentication section, choose the authenticator app (TOTP) option.
- Scan the QR code with the app and type the six-digit code to confirm.
- Save the backup codes the plugin offers. They let you log in if you lose your phone.
- Repeat the process for each user with the Administrator or Editor role. If the plugin lets you require verification by role, enable it for those roles.
Do the first test with your current session still open: open a private window, log in with your password and code, and only then end the original session. That way, if something goes wrong, you can still undo it.
What to do if you lose your phone
- Log in with one of the saved backup codes. Each one is usually valid only once.
- Without the codes, another administrator of the site can disable verification for your user.
- If you’re the only administrator and have lost everything, you can disable the plugin by renaming its folder in
wp-content/plugins, using the cPanel File Manager or FTP. With the folder renamed, WordPress deactivates the plugin, and login again asks only for the password. Afterward, reinstall the plugin and register your new phone.
Best practices
- Prefer an app over SMS. Codes sent by text message can be intercepted, for example in SIM-swap scams.
- Also enable it on your email and on your domain registration account, if they offer it. Whoever controls the email can often reset the other passwords.
- Don’t store the backup codes in the same place as the password, such as the same text file on your computer.
- Change your password if you suspect a break-in, and use a unique password for each service. Two-factor authentication reduces the risk, but it doesn’t replace a strong password.
- Keep WordPress, themes, and plugins up to date. Verification protects the login, but it doesn’t protect against flaws in an outdated plugin.
If the site has already been hacked
Enabling two-factor authentication after a break-in doesn’t remove what the attacker left on the site. In addition to malicious code, they may have created new administrator users that keep working even with your login protected. See how to use AI to remove viruses from a WordPress site or learn about the virus and malware removal service for hacked sites.
Frequently asked questions
What is two-factor authentication?
It’s an extra layer of security at login. In addition to your password (something you know), the system asks for a code generated by your phone (something you have). Even if your password leaks, an attacker still needs the device.
Are two-factor authentication and two-step verification the same thing?
In practice, yes. The name varies by service: cPanel uses “two-factor authentication,” while other services use two-step verification, 2FA, or MFA. All of them require your password plus a second element.
Do I have to pay to enable it in cPanel?
Two-factor authentication is a built-in cPanel feature, which your host may or may not have enabled. If the option doesn’t appear in the Security menu, ask your hosting provider’s support.
Do I need to install a plugin to have 2FA in WordPress?
Yes. WordPress doesn’t include this feature by default. Security plugins and plugins specific to 2FA add this function.
Does two-factor authentication protect FTP and domain email?
No. It protects the login to cPanel and WordPress, as configured in each one. FTP accounts and email accounts have their own passwords, so they should be strong and unique, and you should remove the ones you no longer use.
What happens if I change phones?
Before getting rid of your old device, register the app on the new one. Many apps let you export your accounts. If that isn’t possible, disable verification in cPanel and WordPress, and then enable it again on the new phone.
Can I use the same authenticator app for cPanel and WordPress?
Yes. Each service appears as a separate account inside the same app, with its own code.