Skip to main content
WordPress made easy with the drag & drop Total WordPress Theme!Learn More

How to Enable 2-Factor Authentication in WordPress

Last updated on:

In this tutorial we’ll be learning how to enable two-factor authentication for WordPress using a free plugin called Duo Two-Factor Authentication. Duo Security is an enterprise-level, renowned security service which is trusted by hundreds of companies like Sony, Microsoft, Accenture, Toyota and Yelp. It’s extremely secure and equally easy to use.

What is Two-Factor Authentication?

In very simple terms, two-factor authentication is an additional security measure intended to enhance the security of the site/product it safeguards. It consists of two distinct authentication stages:

  1. The account password
  2. A dynamically generated security code called a One Time Password (OTP)

Take Google accounts for example. With two-factor authentication enabled, when you sign in to your account from a new or previously unused IP address, the first barrier is your password. Next, Google will send an SMS or call your registered mobile number and send a 6 digit code. Only when you enter the code, you are granted access to your account.

Until you authorize your PC (in essence, a particular IP address) to be a known access point, you will always have to login using these two steps. Once you authorize an IP address, the 2nd confirmation code (OTP) won’t be necessary.

Advantages Of Two-Factor Authentication

As you can imagine, the benefits of two-factor authentication is invaluable in an insecure environment. Even if someone came to know your password, he won’t be able to gain access to your account. The 2nd authentication stage, i.e. the OTP would stop him. Check out this awesome explanation by Duo Security. However, in ridiculously rare cases, where the perpetrator has access to both your password and phone, then you’re done for.

Prerequisites

Enabling two-factor authentication requires the following devices to be with each account holder at all times.

  1. A mobile phone or a tablet. Preferably a smartphone, since international calls/texts require chargeable credits. Android, iOS and BlackBerry devices are the recommend smartphones.
  2. An active phone number (either this or a recommended smartphone with Internet access)
  3. A Duo Security account

Setting up the Duo Security Account

The first thing that you need to do is create a free Duo Security account. You must use your active phone number in order to register an account. The following steps show you how:

create-duo-account

First off, select the Free Account option from the pricing page. Fill in the details carefully. For the phone number, make sure that your use the Country Code followed by a space, then the phone number.

Since I’m from India, my Country Code is +91. So I’ve entered +91 XXXXXYYYYY.

create-duo-account-step-2

In Step 2, you can use a different company size. Since we’re using Duo Security to protect our WordPress site, we select CMS under ‘What do you want to protect?’ Rest of the settings is fine.

duo-activation-link

As soon as you register, Duo will send you an activation link. Open your inbox and click on that link. You’ll be redirected to a similar page:

setup-duo-account-welcome

  • Under Phone Number make sure that you use the same one you’ve used in the first step of the Duo registration process.
  • Once you’ve entered all the details, click on Submit.
  • Wait a few seconds and click on either Text Me or Call Me.
  • If you don’t receive a text (I didn’t) then try the call function.
  • If it still doesn’t work, recheck the number and ensure that your cell has a signal.

Configuring the Duo Admin Panel

Once you’ve setup the Duo account you’ll automatically be redirected to the admin panel.

05-create-new-integration-duo-security

  • If you’re picking up from here, login to your account and from the left menu, select Integrations > New Integration
  • Under Integration Type select WordPress
  • The Integration Name can be anything you want – we’ll use “My WP Site” in this tutorial
  • Click on Create Integration

integration-details-duo-admin-interface

Connect Duo Security to your WordPress Site

We will now copy the secret keys and paste them in our WordPress site. This will establish a connection between our WordPress site and Duo Security.

connect-duo-security-to-wp-plugin

To do this, go to WP Dashboard > Settings > Duo Two-Factor. The required settings are available in this page. Copy the keys from the Duo Security admin interface and paste it the respective fields. Hit Save Changes and the connection is established. Now two-factor authentication is enabled in your site. In next step, we will setup an authentication method.

Add an Authentication Method to Each WordPress User

In order to do this, you will first need to logout of the WP Dashboard and login again. Post login, you should see something like this:

08-setup-add-device-to-user-wordpress-duo-security-1

This tells us that the user (in this tutorial, ‘john’) does not have an authentication method activated for Duo Security.

Authentication Methods offered by Duo Security

The available Authentication Methods available under a free account is as follows:

  1. Phone call (mobile or landline)
  2. SMS
  3. BlackBerry
  4. Android
  5. iOS

The Phone and SMS method requires retail credits. You have 1000 credits to begin with, which you’ll have to buy once they’re spent. The call/SMS credit charge depends on country which the phone number belongs to. For India, it’s 5 credits per call or SMS. I’ve tested both Phone and Android as Authentication Methods and found them to be working.

How to add an Android device to your Duo Security Account

Since most of us own a smartphone, I’ve created an in-depth tutorial for the Android Authentication Method. You can just as easily setup other devices, by following the on-screen instructions.

The main advantage of using an Android device as an authentication method (represented as Tablet), is the fact that you don’t need an active mobile carrier signal. A working Internet connection in the respective device is all that’s required. So we select Tablet under Choose Your Device

08-setup-add-device-to-user-wordpress-duo-security-2

I’ve selected Android. If you own an iPad or iPhone, select iOS.

08-setup-add-device-to-user-wordpress-duo-security-3

Now you need to install the respective mobile app. Check the confirmation box and hit Continue

08-setup-add-device-to-user-wordpress-duo-security-4

Open the Duo Mobile app in your device and click on the Key icon. This will launch a barcode scanner.

08-setup-add-device-to-user-wordpress-duo-security-5

Scan the barcode from the screen to transform your tablet/phone into a recognized authentication device.

08-setup-add-device-to-user-wordpress-duo-security-6

This confirmation shows that the user ‘john’ has an Android device as a recognized or Enrolled Device in his account.

08-setup-add-device-to-user-wordpress-duo-security-7

Logging in with Two-Factor Authentication

Everything is now setup. Keep your phone/tablet nearby and navigate stage one by entering your password. Now you’re at the Two-Factor Authentication junction.

09-logging-in-after-proper-setup-0

You can select Duo Push or Passcode as a login method. If you’ve selected Duo Push, click on Log In. You should see a notification in your Android/iOS device.

09-logging-in-after-proper-setup-1

Launch the Duo Mobile app and select Approve. You should immediately see something like this:

09-logging-in-after-proper-setup-2

You have now successfully overcome the 2nd stage of the two-factor authentication process and can access the WP Dashboard. Congratulations! If you had selected Passcode as a login method, then you’ll find the passcode inside the Duo Mobile app. You will have to manually type it in and press Log In.

Sneak Peek at the Mobile Authentication Method

Remember I said that I tried the Mobile authentication method as well? Well, the on-screen instructions we detailed and easy to follow. This screenshot shows that a Mobile device is added under the user ‘sourav’

09-phone-activation-method-one

Remember this form of authentication will cost you credits. You can either use a Voice call or and SMS each time you login. I found the Voice Call feature to be most impressive. All I had to do was answer the call and press any button. That’s it – I was automatically logged in.

phone-activation-method-2

Conclusion

Enabling two-factor authentication is one of the best ways to prevent unauthorized access. It serves as an excellent security practice. Albeit it takes a bit more time to login to your WordPress site, but the extra work is rewarded with peace of mind.

There are other plugins in the market that help you setup two-factor authentication. The Solid Security Pro plugin is an excellent example. The plugin costs $80 for 2 sites and $150 for unlimited licenses. It is loaded with a buck load of awesome security measures when compared to its free counterpart. I selected Duo Security since it is free for all to use. So over to you – what do you think of this additional security measure?

2-factor-authentication-wordpress
Article by Sourav WPExplorer.com guest author
Subscribe to the Newsletter

Get our latest news, tutorials, guides, tips & deals delivered to your inbox.

8 Comments

  1. leowys

    Hello! You can use Google Autenthicator via free plugin too.

    • Sourav

      Hi Leowys,

      Thanks for your input. There are a couple of advantages when it comes to Duo Security – it can generate OTPs via SMS and phone call. 😉

      Best,
      Sourav

  2. mrminsf

    Actually I’m more interested in the Google Authenticator approach: Not that I really have any love for Google – but I need yet another account/app like a hole in the head.

    • Sourav

      Looks like Google Authenticator is very much in demand. Great then, we’ll have a tutorial on it soon!

  3. Nick vd Veerdonk

    Thanks for a great article Sourav, bookmarked, and I’ll be looking forward to the Google Authenticator post!

  4. Dan Lester

    For those asking about Google… Our “Google Apps Login” plugin allows you to add Google single-sign-on to your WordPress site. Many users do this knowing that it automatically brings 2-factor Auth to your website as a side-effect, as long as you have it enabled for your Google accounts.

    The premium version also allows you to lock things down so that users can’t access WordPress using any regular username/password combination, so your entire Google Apps domain must use Google sign-on.

    Please get in touch if you’d like more information, or see the free plugin here: http://wordpress.org/plugins/google-apps-login/

  5. Michael McCrystal

    An important deal-breaker I discovered while doing some add’l research on this: 2-factor authentication is not compatible with ManageWP, a site I depend on to manage my studio’s large # of client WP sites. It’s a devil’s bargain to choose between upgraded 2-factor security and huge time/cost savings associated with being able to manage a large portfolio of sites in one place.

  6. Two Fator Authentication Wordpress Plugins

    Nice list of WordPress Security plugins! However, I would recommend using a separate plugin just for two Factor Authentication! Opt out for Wordfence!

Leave a Reply

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

Learn how your comment data is processed by viewing our privacy policy here.