> ## Documentation Index
> Fetch the complete documentation index at: https://vastai-80aa3a82-docs-cln-3283-cli-tfa-790d53bc8de7f1f3.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# vastai tfa login

Complete 2FA login by verifying your identity with a 2FA code or backup code. On success, saves the session key to `~/.config/vastai/vast_tfa_key`.

## Usage

```bash theme={null}
vastai tfa login [--code CODE] [--method-type METHOD_TYPE] [--secret SECRET] [--backup-code BACKUP_CODE] [--method-id ID]
```

## Options

<ParamField path="--code" type="string">
  2FA code from Authenticator app, SMS, or Email. Exactly one of `--code` or `--backup-code` is required.
</ParamField>

<ParamField path="--backup-code" type="string">
  One-time backup code (alternative to regular 2FA code). Exactly one of `--code` or `--backup-code` is required.
</ParamField>

<ParamField path="--method-type" type="string">
  2FA method type. Choices: `email`, `sms`, `totp`. Only use when you have exactly one method of this type.
</ParamField>

<ParamField path="--secret" type="string">
  Secret token from the previous login step. Required for SMS or Email 2FA (obtained from `tfa send-sms` or `tfa send-email`).
</ParamField>

<ParamField path="--method-id" type="string">
  2FA method ID if you have more than one of the same type. Get the ID from `vastai tfa status`.
</ParamField>

## Examples

```bash theme={null}
# Login with TOTP (Authenticator app)
vastai tfa login --method-type totp -c 123456

# Login with SMS (get code and secret from send-sms first)
vastai tfa login --method-type sms --code 123456 --secret abc123def456

# Login with Email
vastai tfa login -t email -c 123456 -s abc123def456

# Login with backup code
vastai tfa login --backup-code ABCD-EFGH-IJKL
```

## Global Options

The following options are available for all commands:

| Option          | Description                                           |
| --------------- | ----------------------------------------------------- |
| `--url URL`     | Server REST API URL                                   |
| `--retry N`     | Retry limit                                           |
| `--raw`         | Output machine-readable JSON                          |
| `--explain`     | Verbose explanation of API calls                      |
| `--api-key KEY` | API key (defaults to `~/.config/vastai/vast_api_key`) |
