How to Enable Two-Factor Authentication Properly (and Which 2FA Method to Choose)
Turn on two-factor authentication the right way: passkeys, security keys, authenticator apps, push and SMS compared, plus backup codes and recovery.
Table of contents
To enable two-factor authentication (2FA) properly, open the security settings of each important account, turn on 2FA (often called "2-Step Verification" or "multifactor authentication"), choose the strongest method the service supports — a passkey or hardware security key first, an authenticator app second, SMS only as a last resort — and then register a backup method and save your recovery codes before you log out. The last step is the one most people skip, and it is the one that decides whether a lost phone is a minor nuisance or a locked account.
This guide explains how the common 2FA methods differ, which one to pick, and how to set it up without locking yourself out.
Why a password alone is not enough
A password is a single shared secret. If it leaks — through a phishing page, malware, a breach at another site where you reused it, or a guess — anyone who has it can sign in. A second factor means the attacker also needs something you have (a phone, a security key) or something you are (a fingerprint used to unlock a device).
CISA's consumer guidance puts it bluntly: any MFA is better than no MFA. That is the right starting point. But 2FA methods are not equal, and the differences matter most against the attack that defeats most accounts today: phishing.
The 2FA methods, from strongest to weakest
Passkeys and hardware security keys (phishing-resistant)
Passkeys and security keys (such as USB or NFC keys) use the FIDO2/WebAuthn standards. During sign-in, your device signs a challenge with a private key that is bound to the real website's domain. A look-alike phishing domain gets nothing it can use, because the key simply will not answer for the wrong site.
That is why CISA says the only widely available phishing-resistant authentication is FIDO/WebAuthn, and why NIST SP 800-63B-4 — the US federal authentication guideline revised in July 2025 — treats this kind of "verifier name binding" as phishing-resistant while explicitly stating that one-time passwords are not. A passkey can sometimes replace the password entirely; we cover how that works in Passkeys explained.
Choose this when: the service supports passkeys or security keys. Use it for your email, password manager, cloud and developer accounts first.
Authenticator apps (TOTP codes)
Authenticator apps generate a new six-digit code every 30 seconds using the TOTP algorithm defined in RFC 6238. When you enrol, the site shows a QR code containing a shared secret; your app and the server then both derive the same code from that secret and the current time. Nothing travels over the phone network, so SIM-swap attacks do not apply.
The weakness: you type the code, so a convincing fake site can ask for it and relay it to the real site within seconds. NIST states plainly that OTP authentication is not phishing-resistant.
Choose this when: passkeys or security keys are not offered. It is a large step up from SMS.
Push notifications (with number matching)
Some services send an "Is this you?" prompt to an app on your phone. Plain approve/deny prompts are vulnerable to MFA fatigue or "push bombing": an attacker who already has your password triggers prompt after prompt until you tap Approve by mistake or just to make it stop.
CISA's number-matching fact sheet describes the fix: the login screen shows a number that you must type into the app, so you cannot approve a request you are not looking at. CISA calls it one of the best interim mitigations, while noting it is still weaker than phishing-resistant MFA. NIST's 2025 revision also says verifiers should limit how many push notifications they send.
Choose this when: it is what your employer or service uses — and never approve a prompt you did not trigger.
SMS and voice codes
Codes sent by text message or phone call are the most widely available method and the weakest. They can be phished like app codes, and phone numbers can be hijacked through SIM swaps or number porting. NIST classifies authentication over the public phone network as a restricted method: services that use it should offer an alternative and warn users of the risks.
Choose this when: it is the only option. It still blocks the most common password-only attacks. Email-based codes are weaker still; NIST says email shall not be used for out-of-band authentication.
Quick comparison
| Method | Stops password reuse | Stops phishing | Stops SIM swap | Main risk |
|---|---|---|---|---|
| Passkey / security key | Yes | Yes | Yes | Losing your only key or device |
| Authenticator app (TOTP) | Yes | No | Yes | Codes typed into a fake site |
| Push with number matching | Yes | Partly | Yes | Social engineering, real-time phishing |
| Plain push (approve/deny) | Yes | No | Yes | MFA fatigue |
| SMS / voice | Yes | No | No | SIM swap, phishing |
How to enable 2FA step by step
The menus differ between services, but the process is the same everywhere.
1. Start with the accounts that unlock everything else
Your primary email comes first, because it can reset almost every other password. Then your password manager, Apple/Google/Microsoft account, bank, cloud provider, domain registrar and GitHub or other code hosts. CISA also lists social media, online stores, and gaming and streaming accounts as worth protecting.
2. Find the setting
Look in Settings → Security (or "Sign-in & security") for "Two-factor authentication", "2-Step Verification" or "Multifactor authentication". For example, Google's version is described on its Turn on 2-Step Verification help page. If a service has no such option, CISA suggests asking the company to add it.
3. Add the strongest method first
- Passkey or security key: choose "Add passkey" or "Add security key", then confirm with your device's screen lock or by touching the key.
- Authenticator app: choose "Authenticator app", scan the QR code with your app, and type the current code to confirm. If you cannot scan, most sites show the secret as text you can enter manually.
- SMS: only if nothing else is available, and then plan to switch later.
4. Register a second method
One method means one point of failure. Add a second security key, a passkey on another device, or an authenticator app as a fallback. If you use security keys, register at least two and keep the spare somewhere safe.
5. Save your backup codes now
Most services generate one-time recovery codes when you turn on 2FA. GitHub, for instance, documents several recovery methods, including downloadable recovery codes. Store them in your password manager or print them and keep them somewhere secure — not in a plain file on the desktop, and not only on the phone you are protecting.
6. Test it
Sign out and sign back in using the new method, then try a backup code or secondary method on a low-stakes occasion. It is far better to discover a problem now than when your phone is gone.
Avoid locking yourself out
- Back up or sync your authenticator. Some authenticator apps can sync or export accounts; others are tied to one device. NIST notes that when you change devices you should rebind the app and invalidate the old one, or use a sync service that meets its requirements. Check what your app does before you replace your phone.
- Move 2FA before you wipe a phone. Add the new device to each account first, then remove the old one.
- Keep your phone number current with services that still use it for recovery, and add a carrier account PIN if your carrier offers one, to make SIM swaps harder.
- Treat unexpected prompts or codes as a warning. An approval request or SMS code you did not ask for means someone may have your password. Deny it and change the password.
For developers: how TOTP codes are generated
If you are adding 2FA to your own app, TOTP is simple to implement with a maintained library — but do not roll your own crypto. This short example uses the Python pyotp library (install it inside a virtual environment; see our venv guide):
python3 -m venv .venv
source .venv/bin/activate
pip install pyotp
import pyotp
# Generate and store this secret per user, server-side, encrypted at rest.
secret = pyotp.random_base32()
totp = pyotp.TOTP(secret) # defaults: 6 digits, 30-second interval
# URI to render as a QR code for the user's authenticator app
print(totp.provisioning_uri(name="alice@example.com", issuer_name="ExampleApp"))
code = totp.now() # what the user's app would show right now
print(totp.verify(code)) # True
The provisioning URI looks like otpauth://totp/ExampleApp:alice%40example.com?secret=...&issuer=ExampleApp. A few rules from NIST's guidance are worth building in: accept each code only once, rate-limit failed attempts, and allow a small window for clock drift. If you can, offer passkeys as well — TOTP will never be phishing-resistant. For developer accounts specifically, pair 2FA with key-based Git access as described in our SSH keys guide.
The bottom line
Turn on 2FA everywhere it is offered, starting with your email. Prefer passkeys or security keys, use an authenticator app where they are not available, and fall back to SMS only when there is no alternative. Then do the unglamorous part: add a second method, save your backup codes, and test that recovery works. A strong second factor protects you from attackers; a backup plan protects you from yourself.
Frequently asked questions
+Is SMS two-factor authentication still worth using?
Yes, if it is the only option a service offers. It is much better than a password alone. But SMS codes can be phished and phone numbers can be hijacked through SIM swaps, so switch to an authenticator app, a passkey or a security key wherever the service supports one.
+What is the most secure type of 2FA?
Phishing-resistant methods built on FIDO2/WebAuthn: passkeys and hardware security keys. They only work on the genuine website they were registered with, so a fake login page cannot capture anything reusable.
+What happens if I lose my phone with my authenticator app?
You sign in with a backup method: a second registered security key or passkey, a saved backup code, or a recovery method the service offers. That is why you should set up at least two methods and store backup codes before you need them.
+Are authenticator app codes safe from phishing?
No. A six-digit code can be typed into a fake site and relayed to the real one within its validity window. Authenticator apps stop password reuse and credential-stuffing attacks, but only passkeys and security keys stop phishing.
Sources & references
- NIST — SP 800-63B-4, Digital Identity Guidelines: Authentication and Authenticator Management (July 2025)
- NIST — SP 800-63B-4, Section 3: Authenticator and verifier requirements
- CISA — More than a Password (multifactor authentication)
- CISA — Implementing Number Matching in MFA Applications (October 2022)
- IETF — RFC 6238: TOTP, Time-Based One-Time Password Algorithm
- Google Account Help — Turn on 2-Step Verification
- GitHub Docs — Configuring two-factor authentication recovery methods
Spotted an error? See our Corrections Policy.
- #two-factor-authentication
- #2fa
- #mfa
- #passkeys
- #totp
- #security-keys
- #account-security
Dipak SuryawanshiFounder & Editor
Dipak Suryawanshi is a backend developer who works with Java and Spring Boot, focused on building APIs, clean architectures and developer tools. He founded KernelBrief, an independent technology publication based in India, sets its editorial direction and is responsible for everything published on it. Every KernelBrief article is researched and checked against primary sources such as official documentation, vendor advisories and release notes before it is published.
Related articles
Passkeys Explained: How They Work, Why They Beat Passwords, and How to Start Using Them
Passkeys replace passwords with cryptography that can't be phished or reused. How they work, synced vs device-bound passkeys, and how to start.
· 7 min read
Drupal Core Installer Flaw CVE-2026-132165 Is Being Exploited: Who Is Affected and How to Patch
CISA added Drupal core installer flaw CVE-2026-132165 to its exploited list. Affected versions, fixed releases, how to block install.php and what to check.
· 6 min read
NGINX 1.31.10 and 1.30.8 Released as NGINX2Root Fallout Reaches PAN-OS: What to Patch Now
nginx 1.31.10 and 1.30.8 fix a new TLS early-data DoS, days after the NGINX2Root RCE flaws. PAN-OS is affected too. Versions, checks and workarounds.
· 6 min read