← All articles

Setting up 2FA in Magento Admin: step by step with a QR code

Since Magento 2.4, two-factor authentication (2FA) for the admin panel has been mandatory by default. When you sign in, you enter not only your password but also a code on your phone that changes every 30 seconds. Even if someone gets hold of your password, they cannot get in without your phone. In this visual guide you set up 2FA in six steps — in about five minutes.

What do you need?

  • A smartphone (iPhone or Android) with an authenticator app — see step 1.
  • Your Magento Admin login details (username and password).
  • Access to the mailbox linked to your admin account.

Setting up 2FA in 6 steps

App Store search result for 'authenticator' showing Google Authenticator, Microsoft Authenticator, Authy and 1Password.

Install an authenticator app on your phone

Open the App Store (iPhone) or Google Play (Android), search for authenticator and install one of these apps. They are all free and work with Magento:

  • Google AuthenticatorSimple, most widely used
  • Microsoft AuthenticatorHandy if you already use Microsoft 365
  • AuthyWith encrypted cloud backup
  • 1Password / BitwardenIf you already have a password manager

Open the app once after installing it, so you are ready for step 4.

Browser window with the Magento Admin login screen: username, password and an orange Sign in button.

Sign in to your Magento Admin

On your computer, go to the admin panel of your webshop, for example https://www.yourwebshop.nl/admin, and sign in with your username and password as usual.

If 2FA has not yet been set up for your account, Magento will not let you straight in but shows the message: "You need to configure Two-Factor Authorization in order to proceed to your store's admin area. An e-mail was sent to you with further instructions."

Message from the webshop with the subject 'Two-Factor Authorization configuration' and a 'Configure 2FA' button.

Open the configuration link in your mailbox

Magento sends a message to the address of your admin account. Open this message and click the link or button to start the configuration. You arrive at a page in the admin panel with a QR code (see the illustration at the top of this article).

No message received? Check your spam or junk folder. If nothing arrives after a few minutes, the shop's outgoing messages may not be configured correctly — contact your administrator or us.

If several 2FA methods are enabled (for example Google Authenticator and Duo), choose Google Authenticator first. It works with all the apps from step 1.

Authenticator app with a plus button at the bottom right and a menu with the option 'Scan QR code'.

Open the app and choose "Scan QR code"

Take your phone and open the authenticator app from step 1. Tap the plus button (+) — usually at the bottom right or top right — and choose Scan QR code.

  • Google Authenticator: + → Scan a QR code
  • Microsoft Authenticator: + → Other account → Scan QR code
  • Authy: + → Scan QR Code

The first time, the app asks for permission to use the camera. Choose Allow.

A smartphone is held in front of a monitor; the camera recognises the QR code on the Magento screen and shows 'Found'.

Scan the QR code on the Magento screen

Hold your phone in front of the computer screen and point the camera at the QR code that Magento shows. As soon as the code is inside the frame, the app recognises it automatically — you do not need to tap anything.

A new account now appears in the app, for example "Magento Admin: manager@yourwebshop.nl", with a 6-digit code below it that changes every 30 seconds.

Scanning does not work? In the app, choose Enter setup key and type in the text key that Magento shows below the QR code (in the example JBSW Y3DP EHPK 3PXP). For the type, choose Time-based.

The phone shows the code 482 915 with a countdown circle; the same code has been entered in the Magento field 'Authenticator code' above a Confirm button and a green tick.

Enter the 6-digit code and confirm

Type the code that the app is showing at that moment into the Authenticator code field on the Magento screen and click Confirm. Do this while the code is still valid; if the timer is almost at zero, wait a moment for the next code.

If the code is correct, you are signed in immediately. 2FA is now active. Every time you sign in from now on, you enter the current code from the app after your password.

Tip: do not delete the authenticator app and do not wipe your phone without first moving the key (most apps have an export or transfer function). Without the app and without the key, an administrator has to reset your 2FA — see below.

Frequently asked questions and problems

The code keeps being rejected ("Invalid code")

Almost always, the clock on your phone or on the server is slightly out of sync. Set the time on your phone to automatic. In Google Authenticator you can also align the time via ⋮ → Settings → Time correction for codes → Sync now. If you manage several shops, also check that you are reading the right account in the app.

I have a new phone or have lost my phone

A Magento administrator with server access can reset your 2FA link, after which you receive a new configuration message the next time you sign in and repeat steps 3 to 6:

bin/magento security:tfa:reset <username> google

If WEBSHOT manages your hosting, submit a support ticket; we verify your identity and reset the link.

I am not receiving a configuration message

First check the spam folder. If nothing arrives, the address of your admin account may be out of date or the shop is not sending messages. An administrator can change the address under System → Permissions → All Users, or can generate the configuration URL for you directly.

Which 2FA methods does Magento support?

Magento 2.4 ships with four providers by default: Google Authenticator (TOTP, works with all the apps from step 1), Duo Security, Authy (via Twilio) and U2F hardware keys such as a YubiKey. The administrator decides which are active under Stores → Configuration → Security → 2FA. For most organisations, Google Authenticator is the simplest choice.

Can I disable 2FA?

Technically yes (via bin/magento module:disable Magento_TwoFactorAuth), but we strongly advise against it. The admin panel gives access to customer data, orders and payment settings; 2FA is the most effective protection against stolen or guessed passwords and is a requirement in virtually every security audit and PCI-DSS assessment.

Why 2FA is essential for your webshop

The vast majority of break-ins into webshop admin panels start with a leaked or reused password. With two-factor authentication, a password alone is no longer enough: the attacker also needs physical access to your phone. That makes phishing, credential stuffing and brute-force attacks on the admin login virtually hopeless. Combine 2FA with an IP restriction on the admin path, strong unique passwords and regular security patches, and your Magento admin environment is well protected.

Want to know more?

Let's talk
about your project

We respond within one working day with a concrete approach and honest advice.

Or call us directly: +31 485 841 000