CYBER WELFARE

Protect your Digital Privacy

How Two-Factor Authentication Works, Step by Step

Additional resource for the lesson “How Two-Factor Authentication (2FA) Works” — Online Security course

The six digits that appear on your phone are not sent to you, and they are not stored anywhere. Understanding how two-factor authentication works — where the code comes from and why it changes — turns a small ritual into something you can reason about.

A. Why this matters

Two-factor authentication asks for something in addition to your password: usually a temporary code, sometimes a fingerprint, sometimes a tap on a physical key.

Most people use it without knowing what is happening, which is fine until something goes wrong — a new phone, a code that will not work, a moment offline. Understanding the mechanism is what makes those situations manageable rather than alarming.

The key idea: with an authenticator app, nothing travels. Your phone and the service each calculate the same code independently, from a shared secret and the current time.

B. Key concepts

Six ideas about what is actually happening.

One-time password

A code valid for a single use, and usually for a short window. Once used or expired, it is worthless.

Why it matters to you: This is why a code caught by someone watching your screen is of limited value to them. Its lifespan is measured in seconds.

TOTP: the time-based code

When you set up an authenticator app — usually by scanning a QR code — the service and your phone agree on a shared secret. From then on, both calculate the same six digits from that secret and the current time, refreshing roughly every thirty seconds.

Why it matters to you: It explains two things people find confusing: why the app works with no signal, and why a phone with the wrong clock produces codes that are rejected.

The authenticator app

An application holding the shared secrets for all your accounts and displaying their current codes.

Why it matters to you: It works offline, costs nothing, and is stronger than SMS because there is no message to intercept or redirect.

Push approvals

Instead of a code, a notification appears asking you to approve a sign-in.

Why it matters to you: Convenient and generally strong, with one habit attached: read what you are approving. Attackers sometimes send repeated requests hoping one gets tapped automatically.

Backup codes

A short list of single-use codes the service gives you when you enable 2FA.

Why it matters to you: This is your way back in when the phone is lost, replaced or broken. Save them somewhere reachable without the phone, on the day you set things up.

Moving to a new phone

The shared secrets live on the device. Some apps offer an encrypted transfer or backup; others require re-enrolling each account.

Why it matters to you: Worth knowing before you need it. Checking how your app handles a device change takes two minutes and prevents an afternoon of lockouts.

C. A practical example: thirty seconds, twice

You sign in to your email. The password is accepted, and a field appears asking for six digits.

  • Your phone shows 481 205, with a small circle counting down.
  • The service, at that same moment, calculates what the code should be — from the secret you both agreed on when you set this up, and the current time.
  • The two match, and you are in.

Nothing was sent. No message arrived. There was no network involved on your side at all — which is why the app works on a plane.

The same moment, from the attacker’s side

They have your password from a breach. They reach the same screen and need six digits that exist only on a device in your pocket, and that will be different in twenty seconds.

That is the whole mechanism. It is not sophisticated — it is just arranged so that the second proof cannot be obtained from a distance.

D. Try it yourself: a setup that will not lock you out

Fifteen minutes, and the last two steps are the ones that matter later.

Step 1 — Set it up on one account

  • Install an authenticator app if you do not have one.
  • In the account’s security settings, choose the app option and scan the QR code.
  • Enter the first code to confirm the pairing.

Step 2 — Save the backup codes

  • Save them where you can reach them without your phone: printed, or in a password manager you can open on a computer.
  • Not in a note on the same phone that generates the codes.

Step 3 — Check how your app handles a new phone

  • Does it offer an encrypted backup or export? Does it need a separate password for that?
  • Answer this now. It is a two-minute question that becomes a two-hour problem later.

Step 4 — Test the recovery path

  • Sign out and sign back in using a backup code, then confirm the code is marked as used.
  • Knowing the path works is worth more than assuming it does.

Most 2FA problems people describe are not attacks. They are a new phone and no backup codes — which these four steps prevent entirely.

E. Videos, articles and further resources

Independent and institutional sources in English.

NIST — Digital Identity Guidelines, SP 800-63B (Revision 4)
The standard defining how one-time codes and other authenticators are expected to behave. Technical, and the authoritative reference for this mechanism.
https://pages.nist.gov/800-63-4/sp800-63b.html

CISA — Turn on multi-factor authentication
What the second factor actually does, and which accounts should get it first.
https://www.cisa.gov/secure-our-world/turn-mfa

NCSC (UK) — Turn on 2-step verification
Setting it up on the account that matters most, in plain steps.
https://www.ncsc.gov.uk/collection/top-tips-for-staying-secure-online/activate-2-step-verification-on-your-email

NCSC (UK) — Passkeys are more secure than traditional ways to log in
Passkeys replace the code entirely with a check your device performs. Same purpose, less to type.
https://www.ncsc.gov.uk/blogs/passkeys-are-more-secure-than-traditional-ways-to-log-in

Google Safety Center — Security tips
Setup and recovery steps if your accounts run through Google. Platform documentation rather than independent guidance.
https://safety.google/security/security-tips/

NCSC (UK) — What to do if your account is hacked
Steps to take when you lose control of an account. Worth reading before you need it.
https://www.ncsc.gov.uk/section/respond-recover/hacked-accounts

Links checked in August 2026.

F. The Cyber Welfare Framework: Skills, Awareness, Secure Behavior

This lesson sits on the Skills pillar at level FL2 and is deliberately mechanical: it is the resource to come back to when something does not work.

Skills

  • Setting up an authenticator app and pairing it with an account.
  • Saving, using and regenerating backup codes.
  • Moving a second factor to a new device without losing access.

For professionals and organizations

  • Documenting the device-change procedure before people need it, rather than handling each case as a support request.

Awareness

  • Understanding that TOTP codes are calculated, not transmitted — which is why they are harder to intercept.
  • Recognising that a rejected code is often a clock problem rather than an attack.
  • Knowing that push approvals require reading, not reflex.

For future instructors and ambassadors

  • Explaining the shared secret and the clock. It is the detail that makes the whole thing click for most people.

Secure Behavior

  • Keeping backup codes somewhere independent of the phone.
  • Checking, before changing devices, how the second factor will move.
  • Reading push notifications rather than approving them automatically.

For organizations

  • Preferring app-based or hardware factors over SMS wherever the platform allows it.

G. Questions to sit with

  1. If you replaced your phone tomorrow, which accounts would you struggle to get back into?
  2. Where are your backup codes right now? Could you reach them without the phone?
  3. Have you ever approved a push notification without reading it?
  4. Which of your accounts still uses SMS as the second factor, and could move to an app?

H. What to do now

The recommendations (R) and security measures (MS) from the Cyber Welfare database that apply to the mechanism itself.

The second factor

  • R4 — Turn on multi-factor authentication, preferring an authenticator app or hardware token over SMS.
  • R8 — Turn on login alerts, so an attempt to sign in reaches you even when it fails.
  • MS17 — Give the email linked to your bank a strong credential and a second factor.

The device that generates the codes

  • R5 — Set a six-digit PIN on mobile devices.
  • R6 — Keep software up to date, including the authenticator app.
  • R7 — Keep the screen lock timeout short.
  • MS4 — Use an alphanumeric passcode of 8 characters or more.

Minimum commitment: Your second factor is only as protected as the phone holding it.

Four steps, in this order

  1. Set up an authenticator app on one critical account.
  2. Save the backup codes somewhere independent of the phone.
  3. Check how your app handles moving to a new device.
  4. Make sure the phone itself has a strong passcode and a short lock timeout.

The middle two steps are the ones almost everyone skips, and the ones that decide whether 2FA protects you or locks you out.

In short

  • TOTP codes are calculated on both sides from a shared secret and the clock — nothing is transmitted.
  • That is why the app works offline, and why a wrong clock breaks it.
  • Backup codes are the recovery path. Save them on day one.
  • Push approvals are strong, provided you read them.

Related resources in this course

The reasoning behind it, and the choice of method:

Discover more companion resources from the online courses of the Protect Your Digital Privacy programme.

If you would like to follow the whole path, the Cyber Welfare Program is free and open to everyone.

→ Join the Cyber Welfare Program