What Is a 2FA Secret Key and How to Keep It Safe
What Is a 2FA Secret Key and How to Keep It Safe
When you switch on two-factor authentication with an authenticator app, most people scan a QR code, type in the first six-digit code, and never think about it again. Hidden inside that QR code, though, is the single most important piece of your 2FA setup: the secret key.
Understanding what that key is, where it lives and who could misuse it will help you avoid the two classic 2FA disasters: getting locked out because the key is gone, and getting compromised because the key leaked.
What the secret key actually is
The secret key is a random value created by the website when you enable app-based 2FA. The site keeps one copy and gives you the other. Your authenticator app combines that key with the current time to produce a fresh code every 30 seconds, following the TOTP standard (RFC 6238).
The key you see on screen is usually written in Base32, which uses only the capital letters A to Z and the digits 2 to 7. It might look like this:
JBSWY3DPEHPK3PXP
Some sites display it in groups of four characters with spaces, such as JBSW Y3DP EHPK 3PXP, to make it easier to read. The spaces are only for readability; most authenticator apps ignore them, and lowercase letters are usually accepted too.
The important point is this: the key is the factor. Your phone is not special. Any device or app that holds the same key will generate the same codes. That is very convenient for backups and very dangerous if the key ends up in the wrong place.
What is inside the QR code
The QR code is just a convenient way to deliver the key along with a few labels. If you decode it, you will find a URI in a format first documented for Google Authenticator and now supported by most apps:
otpauth://totp/Example:alice@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example
Here is what each part means:
| Part | Meaning |
|---|---|
otpauth:// |
Tells the app this is a one-time password setup link. |
totp |
The type: time-based codes. The alternative, hotp, is counter-based. |
Example:alice@example.com |
The label: usually the service name and your account name, shown in your app's list. |
secret= |
The Base32 secret key. This is the only truly sensitive part. |
issuer= |
The service name, used by apps to label the entry and sometimes to pick an icon. |
A URI may also include optional parameters: algorithm (SHA1, SHA256 or SHA512, default SHA1), digits (6 or 8, default 6) and period (default 30 seconds). Most services leave these at their defaults. Be aware that some apps ignore non-default values, which can produce codes that never match.
Because the secret sits in plain text inside the URI, a QR code is exactly as sensitive as the key itself. A photo of the QR code is a copy of your second factor.
Finding the "can't scan?" option
Sometimes you cannot scan a QR code: you are setting up 2FA on the same phone that displays it, the camera will not focus, or you want to store the key somewhere other than an app. Almost every service offers a text version, but the link is often small and easy to miss.
Look for wording along these lines on the 2FA setup screen, right below or beside the QR code:
- "Can't scan the QR code?"
- "Enter this key manually" or "Enter a setup key"
- "Use a text code instead" or "Show secret key"
- "Trouble scanning?"
Menu names may vary slightly by version and by service. If you still cannot find it, look in the service's help pages for "authenticator app setup key".
When you enter the key manually in an authenticator app, you will normally choose "Enter a setup key" or a similar option, give the entry a name, paste the key and keep the type set to "time-based". If the service asks you to confirm with a code before activating 2FA, do it right away so you know the key was entered correctly.
What happens if someone gets your key
A leaked password is bad. A leaked 2FA key on top of it means the second layer is effectively gone, and the damage is quiet:
- Codes are generated forever. A TOTP key does not expire on its own. Whoever has it can produce valid codes until you disable and re-enable 2FA for that account.
- You get no warning. Generating codes happens entirely offline. Nothing alerts you that a second copy of your authenticator exists.
- It combines with other leaks. Passwords leak through data breaches and reuse. If an attacker later obtains your password, the stored 2FA key turns that into full access.
Common ways keys leak are surprisingly ordinary: a screenshot of the setup page that syncs to a cloud photo library, a QR code pasted into a chat to "send it to my other phone", a text file called 2fa-keys.txt on the desktop, or a key shared with a colleague over email.
Never share screenshots of the setup page
This deserves its own heading because it is the most common mistake. A screenshot of a 2FA setup screen contains either the QR code, the text key or both. Once it exists, it can travel to places you no longer control:
- Automatic photo backups to cloud services.
- Chat apps that keep media on their servers.
- Support tickets, forums and help requests where you ask "why isn't this working?"
- Old phones you sell or hand down without wiping them properly.
If you need help with a setup, describe the problem without showing the key. If you have already shared a screenshot, the safe response is to reset 2FA for that account: disable it, enable it again, and the old key stops working.
Safe ways to store your keys
Losing access is the opposite risk. If your only copy of the key lives in an authenticator app on one phone, and that phone is lost or reset, you will depend on recovery codes or a slow account recovery process. A good setup keeps a backup without spreading the key around.
Option 1: an encrypted 2FA vault
A dedicated vault stores your keys encrypted and shows live codes from them, so you can reach your codes from more than one device. When choosing one, check that keys are encrypted at rest, that the account itself is protected with a strong password, and that you can export your keys if you ever want to move. A 2FA vault like the one on this site is designed for people who manage codes for many accounts and want them in one organised, protected place.
Option 2: a password manager with TOTP support
Many password managers can store a TOTP key next to the login and show the current code. This is very convenient. The trade-off is that your password and second factor now sit in the same place, so the password manager itself must be protected by a strong master password and its own 2FA.
Option 3: offline paper or encrypted offline storage
For your most important accounts, such as your main email, a written copy of the key or the recovery codes stored somewhere physically secure is hard to beat. Paper cannot be hacked remotely. Write clearly, label which account it belongs to, and keep it somewhere you would keep other important documents. An encrypted file on an offline drive is a digital equivalent.
Do not forget recovery codes
Most services also give you a set of one-time recovery codes when you enable 2FA. They are separate from the TOTP key and are your last resort if everything else fails. Store them with the same care as the key, and never in the same unprotected file.
A quick checklist
- Save the key or recovery codes somewhere safe at the moment you enable 2FA, not later.
- Do not screenshot the setup page, and delete any screenshots that already exist, including from cloud photo backups.
- Never send a key or QR code through chat or email.
- Use authenticator apps or vaults that encrypt keys and protect access with a password or device lock.
- If you suspect a key has leaked, reset 2FA on that account immediately.
FAQ
Is the 2FA secret key the same as a recovery code?
No. The secret key generates new codes indefinitely. Recovery codes are a fixed list of single-use codes meant for emergencies. Both are sensitive, but they work differently.
Can I get the secret key back from my authenticator app?
Some apps let you export entries, often as a QR code or an encrypted backup file; others deliberately do not. If yours does not, the reliable way to get a new key is to disable and re-enable 2FA on the service while you are still logged in.
Is it safe to paste my key into a website?
Only if you trust the site, because the key is your second factor. Prefer tools that generate the code without storing the key unless you ask them to, and never paste keys into sites you found through unsolicited messages.
Does changing my password invalidate my 2FA key?
Usually not. The key stays valid until 2FA is reset for the account. If you believe the key was exposed, reset 2FA as well as the password.
New posts
Most viewed
- How to Set Up Two-Factor Authentication on Instagram 25
- How to Turn On 2-Step Verification for Your Google Account 21
- Managing 2FA for Many Accounts: A System That Doesn't Break 20
- Can Two-Factor Authentication Be Bypassed? Real Threats and How to Defend 20
- Lost Your Phone? How to Recover Access to Your 2FA Accounts 19