Skip to content
OTP Generator

AWS 2FA code generator

Paste your AWS two-factor secret key to get the current 6-digit login code, the same one your authenticator app shows.

Find it under “Can’t scan the QR code?” when you turn on 2FA. Only have the QR?

2Your code will appear here
Paste a key to start
Calculated in your browser. Your key is never sent anywhere.
On this page

Amazon Web Services calls two-factor authentication MFA, and a virtual MFA device is simply an authenticator app using TOTP. You can assign one to the root user of an AWS account or to individual IAM users. AWS offers a Show secret key option during setup, and that key, pasted above, generates the 6-digit MFA code.

Root user credentials can do almost anything in an account, including closing it, so AWS strongly recommends MFA there. Because the key is so powerful, this page keeps it in your browser and never transmits it. Store root MFA keys with great care, ideally in a team password vault with restricted access, and do not rely on one browser tab.

How to find your AWS secret key

  1. For the root user: sign in as root, open the account menu (top right) and choose Security credentials. For an IAM user: open the IAM console → Users → select the user → Security credentials.
  2. In the Multi-factor authentication (MFA) section, choose Assign MFA device.
  3. Give the device a name and select Authenticator app as the device type.
  4. On the setup screen, choose Show secret key and copy it. Console layout may vary slightly over time.
  5. Store the key securely before entering codes.

How to log in to AWS with the code

  1. Paste the AWS secret key into the generator at the top of this page.
  2. AWS asks for two consecutive codes. Enter the current 6-digit code in MFA code 1.
  3. Wait for the generator to show the next code (about 30 seconds), then enter it in MFA code 2 and choose Add MFA.
  4. On later sign-ins, enter a fresh code from this page when AWS asks for your MFA code.

AWS 2FA tips

  • AWS requires two consecutive codes during setup. Do not enter the same code twice; wait for it to refresh.
  • AWS supports multiple MFA devices per user. Register a second device, such as a hardware key, so losing one does not lock you out of root.
  • For CLI or API access with MFA, you will use aws sts get-session-token with the MFA serial number and a current code from this page.

Your AWS key is processed only in this browser and is never uploaded. Keep a copy in an authenticator app or password manager as well.

AWS 2FA FAQ

What is the difference between root and IAM MFA?

Root MFA protects the account owner's credentials, which have unrestricted access. IAM MFA protects individual users you create. Each has its own MFA device and secret key, set up from separate places in the console. Losing one does not affect the other.

AWS says my MFA codes are out of sync. What should I do?

Confirm that your device clock is accurate. In the IAM console, you can resynchronise a virtual MFA device by entering two consecutive codes. Then try signing in again with a fresh code.

Does this work with IAM Identity Center?

IAM Identity Center (formerly AWS SSO) has its own MFA settings, often with authenticator app support. If it gives you a TOTP secret key during registration, this generator will produce valid codes for it.

I lost the MFA key for the root user. How do I recover?

AWS provides a root MFA recovery process that verifies the account's email and phone number. Use the official sign-in page for this. To avoid it, register multiple MFA devices and store keys securely.

Get your AWS code

Paste the AWS setup key and copy the current 6-digit code in seconds.