atuinsh/atuin · error

unexpected two-factor requirement during registration

Error message

unexpected two-factor requirement during registration

What it means

During `atuin register`, the server responded with AuthResponse::TwoFactorRequired. Two-factor is only expected during login, not account creation, so the CLI treats this as an unexpected server state and aborts. It indicates a mismatch between what the local client is doing (registration) and the server-side state of the account (which apparently already exists with 2FA enabled).

Source

Thrown at crates/atuin/src/command/client/account/register.rs:93

                        let is_hub_token =
                            auth_type.as_deref() == Some("hub") || session.starts_with("atapi_");

                        if is_hub_token {
                            meta.save_hub_session(&session).await?;
                        } else {
                            meta.save_session(&session).await?;
                            println!(
                                "\nNote: Your account has not been fully migrated to Atuin Hub."
                            );
                            println!(
                                "Sync will continue to work, but you can visit hub.atuin.sh to \
                                 create a new Hub account and link it to your existing CLI \
                                 account."
                            );
                        }
                    }
                    AuthResponse::TwoFactorRequired => {
                        bail!("unexpected two-factor requirement during registration");
                    }
                }

                let _key = paseto_v4::Key::try_load_or_generate(&settings.key_path)?;

                println!(
                    "Registration successful! Please make a note of your key (run 'atuin key') \
                     and keep it safe."
                );
                println!(
                    "You will need it to log in on other devices, and we cannot help recover it \
                     if you lose it."
                );
            } else {
                // Interactive registration: delegate to the browser OAuth flow.
                // Registration on Hub happens on the website; the CLI just needs
                // to authenticate afterwards.
                super::login::Cmd {

View on GitHub (pinned to c0c717ab04)

Solutions

  1. Use `atuin login` (with your 2FA code when prompted) instead of `atuin register` — the account already exists.
  2. Choose a different username if you truly want a new account.
  3. Check you are pointing at the intended sync server (`sync.address` in config) — you may be hitting a different instance than expected.
  4. If the old account is unwanted, delete it on the server before registering the same username.

Example fix

// before
atuin register --username ellie --password '...'
// error: unexpected two-factor requirement during registration
// after
atuin login --username ellie   # enter password + 2FA code when prompted
Defensive patterns

Strategy: validation

Validate before calling

# check whether the account exists before registering
atuin login --username "$USER" --password-stdin < /dev/null 2>&1 | grep -qi 'two-factor\|incorrect' && echo 'account likely exists; use atuin login'

Prevention

When it happens

Trigger: Running `atuin register --username <u> --email <e> --password <p>` against a sync server where the username already has an account with two-factor authentication enabled, so the server replies TwoFactorRequired instead of a registration success.

Common situations: Re-registering against the same server after already creating an account; pointing sync_address at a server where the username is taken by a 2FA-enabled account; stale muscle memory trying to 'reset' an account by re-registering instead of logging in.

Related errors


AI-assisted analysis of atuinsh/atuin@c0c717ab04 (2026-09-12). Data as JSON: /api/errors/e5e08e62f3309178. Report an issue: GitHub.