# Authentication in CLI (/docs/cli/auth)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 284 · updated: 2026-07-30 -->
Related: [Connect to sandbox](/docs/cli/connect-to-sandbox.md), [Create sandbox](/docs/cli/create-sandbox.md), [Execute commands in sandbox](/docs/cli/exec-command.md), [List sandboxes](/docs/cli/list-sandboxes.md), [Shutdown running sandboxes](/docs/cli/shutdown-sandboxes.md), [Quickstart](/docs/mcp/quickstart.md)

There are two ways to authenticate with the E2B CLI:

## Option 1: browser authentication [#option-1-browser-authentication]

<Warning>
  This option requires an interactive browser environment.
</Warning>

Run the following command to sign in through your browser:

```bash
e2b auth login
```

This will open your default browser and prompt you to authenticate with your E2B account.

## Option 2: setup environment variables [#option-2-setup-environment-variables]

This is the recommended option for non-interactive environments like CI/CD pipelines, servers, and containers. Set a single environment variable with your API key:

```bash
export E2B_API_KEY=your_api_key_here
```

With the API key set, you can run CLI commands directly without `e2b auth login`. Use CLI version 2.12.1 or later.

<Info>
  Learn more about obtaining and managing your API key on the [API Key page](/docs/api-key).
</Info>

<Warning>
  `E2B_ACCESS_TOKEN` is no longer needed and is deprecated. E2B infrastructure stops accepting it on August 1, 2026. See the [access token deprecation](/docs/migration/access-token-deprecation) for details.
</Warning>
