What Is Two-Factor Authentication?
Two-factor authentication asks for a second proof of identity in addition to your password, so a stolen password alone is not enough. Here is how the main methods compare and how to start.
9 min readUpdated Oct 15, 2026By XPASS Editorial Team

A password is a single secret, and a single secret has a weakness: if anyone learns it, they become you. Passwords get leaked in data breaches, guessed, reused across sites and handed over on fake login pages. Two-factor authentication, often written 2FA, adds a second check so that a leaked password alone does not open the account.
This guide explains the idea, compares the common methods in plain terms, walks through setup and recovery, and is honest about what two-factor authentication cannot do.
The idea: two different kinds of proof
Authentication means proving you are who you claim to be. There are three broad kinds of proof, called factors:
- Something you know: a password, PIN or answer to a question.
- Something you have: your phone, a hardware security key, or a smart card.
- Something you are: a fingerprint, face or other biometric.
Two-factor authentication requires two of these from different categories. A password plus a PIN would both be "something you know", so that is not genuine two-factor. A password plus a code from your phone is. When a service allows more than two, the general name is multi-factor authentication (MFA), and CISA's guidance explains why it matters for everyday accounts.
The benefit is straightforward. An attacker who has your password now also needs to control your phone or key, which is far harder to do from a distance.

The main methods compared
| Method | How it works | Strengths | Weaknesses |
|---|---|---|---|
| SMS code | A text message with a code | Easy, no app needed | Can be intercepted, redirected by SIM swap, or phished |
| Email code | A code sent to your inbox | Easy | Only as safe as the email account itself |
| Authenticator app | An app generates a code that changes every 30 seconds | Works offline, no phone signal needed | Codes can still be typed into a fake page |
| Push approval | A prompt on your phone to approve or deny | Fast | Users approve prompts they did not start when tired or rushed |
| Hardware security key | A physical key you tap or insert | Resists phishing, very strong | Must carry it, buy a backup |
| Passkey | A cryptographic key stored on your device, unlocked by fingerprint, face or PIN | Resists phishing, no password to type | Works only on supporting sites and devices |
How authenticator app codes work
Authenticator apps use the time-based one-time password standard, TOTP, defined in RFC 6238. When you enrol, the site and your app share a secret, usually through a QR code. After that, both calculate the same short code from the secret and the current time, so the code changes every 30 seconds and works without any network connection.
Because the secret is stored on your device, treat the device and any backup of the app as sensitive.
Security keys and passkeys
Security keys and passkeys are built on the standards of the FIDO Alliance. Instead of a code you type, your device proves possession of a private key that never leaves it. The key is bound to the real website address, so a fake lookalike page cannot use it. This is why they are considered the strongest option against phishing, which you can read about in how to recognize phishing websites.
NIST's digital identity guidelines describe the same ranking in more technical language. They treat SMS as a weaker, "restricted" method and recommend phishing-resistant options for higher-risk accounts.
Where to turn it on first
You do not need to protect every account on day one. Start where a takeover would do the most damage:
- Your main email account. It is the key to resetting passwords everywhere else.
- Banking, payment and shopping accounts.
- Cloud storage and photo accounts.
- Social media and messaging. Takeovers here are used to scam your contacts.
- Work accounts, following your employer's policy.
- Any password manager.
How to set it up
The steps differ slightly between services, but the sequence is usually the same.
- Open the account's security settings and look for "two-step verification", "2FA" or "multi-factor authentication".
- Choose a method. If you can, pick an authenticator app, a security key or a passkey over SMS.
- For an app, scan the QR code with the authenticator app and enter the first code to confirm.
- Save the backup codes the service shows you. Store them offline or in a password manager, not in a screenshot sitting on the same phone.
- Register a second method or device if the service allows it, such as a second key.
- Test by signing out and signing in again.
A worked example
Sam uses the same password on an old shopping site and on his email. The shopping site is breached, and an attacker tries that password on his email address.
- Without two-factor authentication, the email account opens. The attacker uses password-reset links to take over Sam's other accounts.
- With an authenticator app, the attacker has the password but not the six-digit code. The login fails, and Sam may even receive a notification about the attempt.
The reused password was still a mistake, but the second factor stopped it from becoming a full takeover. Better still, Sam uses a unique password for every site stored in a password manager, and turns on two-factor authentication on top of it.
What to do when you lose a device
Planning for failure is part of the setup:
- Keep backup codes where you can reach them without your phone.
- Add a second device or key if the service supports it.
- Know the service's recovery process. It may involve waiting days or proving your identity.
- If a phone is lost or stolen, sign in on another device and remove the old one from your account, then change the passwords for important accounts.

Limits and things to watch for
- Phishing can still win against weaker methods. A convincing fake page can ask for your password and your six-digit code in real time and pass both to the real site. Security keys and passkeys are designed to block this.
- Approval fatigue is real. If you receive an unexpected push prompt, deny it and change your password, because someone may already have it.
- SIM swapping. Attackers can convince a mobile carrier to move your number to their SIM. Add a PIN or lock on your number if your carrier offers one.
- Your recovery path is the weakest link. If your account can be reset with an email address that has no second factor, that email account is the real target.
- A VPN does not help here. It protects your connection, not your login. See what a VPN cannot protect you from.
Two-factor authentication and your VPN
People often ask how a VPN and multi-factor authentication (MFA) fit together. They protect different things, and they do not replace each other.
- A VPN protects the connection. It encrypts traffic between your device and the VPN server, which matters on networks you do not control.
- Two-factor authentication protects the login. It makes a stolen or guessed password insufficient on its own.
Using both is sensible: the VPN reduces what a shared network can see, and the second factor reduces the damage if a password leaks. Neither one helps against the other's problem. A VPN does not stop a phishing page from collecting your password and code, and a second factor does not stop a café network from reading unencrypted traffic. For the wider picture of where a VPN stops, see what a VPN does and does not protect.
Some practical points when the two meet:
- Your VPN account has a password too. If a VPN service offers a second factor on its account, turn it on. If it does not, use a long unique password. Treat the username and password for your VPN like any other credential.
- Sign-in alerts may mention a new location. When you browse through a VPN, a service may see your login coming from a different place than usual and ask for an extra check or send a warning. That is the service doing its job, not a fault. Complete the check, and do not disable your second factor to avoid it.
- Time-based codes do not depend on the VPN. An authenticator app computes codes from the shared secret and the clock on your device, so it works whether or not the VPN is connected. If codes are rejected, the cause is usually a wrong device clock, not the VPN.
- Push approvals travel over the internet. If a push prompt is slow to arrive, a weak connection, not the second factor itself, is often the reason. Check the connection before you assume the prompt failed.
- Public Wi-Fi is where both help. On a shared network, the VPN protects the traffic and the second factor protects the account. The guide to staying safer on public Wi-Fi shows the habits that go with them.
Password managers: the partner of two-factor authentication
A password manager stores a unique, long password for every site, so that one breach cannot unlock your other accounts. It pairs naturally with a second factor, but there are choices to make.
- Protect the manager itself first. The manager's master password should be long and used nowhere else, and the manager account should have two-factor authentication turned on. If you lose the master password, many managers cannot recover it for you, so keep an emergency recovery option offline.
- Autofill helps against phishing. A manager fills in a password only on the site address it saved. If it refuses to fill a login on a page that looks right, stop and check the address, because you may be on a fake page. That behaviour makes managers a quiet anti-phishing tool.
- Where to keep authenticator codes. Some managers can generate one-time codes too. That is convenient, but it puts the password and the second factor in the same place, so a single compromise would expose both. For important accounts, many people keep the codes in a separate authenticator app or use a hardware key.
- Keep backup codes safe. Store recovery codes in the manager or printed in a safe place, not in a screenshot on the phone that you might lose.
- Share carefully. If a family or team shares a manager, do not share the master password in a chat message. Use the manager's own sharing feature.
A VPN does not replace a password manager and a password manager does not replace a VPN. One handles what you type, the other handles the path the traffic takes.
A short setup plan for a new device
Here is a sequence you can follow when you set up a new phone or laptop, combining the three tools:
- Install a password manager and create a strong master password. Turn on two-factor authentication for it.
- Turn on two-factor authentication for your email, using an authenticator app or a security key.
- Save the recovery codes offline.
- Sign in to your other important accounts and enable a second factor on each.
- Install your VPN app and sign in with the credentials from your account page. Store them in the password manager.
- Test: sign out of one service, then sign in using your password manager and second factor, with the VPN both off and on, to make sure everything works in both states.
Summary
Two-factor authentication means a stolen password is no longer enough. Authenticator apps, security keys and passkeys are stronger than text messages, and any second factor is better than none. Turn it on first for your email and money accounts, save the backup codes, and stay alert for fake login pages, since they are what the remaining attacks rely on. If you want to protect your connection on shared networks as well, you can look at XPASS pricing.
Frequently asked questions
What are the three kinds of factors?
Something you know, such as a password or PIN; something you have, such as a phone, a security key or an authenticator app; and something you are, such as a fingerprint or face. Two-factor authentication combines two different kinds.
Is a text message code good enough?
It is much better than a password alone, and a reasonable first step. Authenticator apps and security keys are stronger, because text messages can be intercepted, redirected through a SIM swap, or tricked out of you on a fake page.
What happens if I lose my phone?
You use the recovery options you set up in advance, usually backup codes or a second registered device. Save the backup codes somewhere safe and separate from the phone before you need them.
Can a VPN replace two-factor authentication?
No. A VPN protects the connection between your device and the VPN server. It does nothing to stop someone from logging in with a stolen password, which is what two-factor authentication is designed to prevent.
Does using a VPN affect my two-factor codes?
Authenticator app codes are calculated from the secret and your device clock, so they work with or without a VPN. Sign-in alerts about a new location are possible when you browse through a VPN, and you should complete any extra check the service asks for.
References
About the author

Bob Kanokphon Thongdee
- Founder of XPASS VPN
- Co-founder of eSIMonline.asia
- More than 7 years in online marketing
- Founder of Cojourney Visa and Cojourney Travel
Need a VPN for a short trip or a busy month?
XPASS sells prepaid passes for a set number of days. You pay once and nothing renews automatically.
See passesKeep reading

Privacy Guides
How to Recognize Phishing Websites
Phishing websites imitate real services to steal your login or card details. This guide shows the warning signs worth checking, a calm routine for suspicious links, and what to do if you entered details.
9 min read

Privacy Guides
What a VPN Cannot Protect You From
A VPN secures the connection, not the person using it. This guide covers phishing, malware, ransomware, identity theft, data breaches, email privacy and other risks it cannot solve, and what to do about each.
9 min read

VPN Security
HTTPS vs VPN: What Each One Protects
HTTPS secures the connection between your browser and a website. A VPN secures the path between your device and the VPN server. They overlap less than most people think.
9 min read