> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

export const GCell = ({children, className}) => <div className={`grid-table-cell ${className || ""}`} role="cell">
    {children}
  </div>;

export const GTH = ({children, className}) => <div className={`grid-table-th ${className || ""}`} role="columnheader">
    {children}
  </div>;

export const GRow = ({children}) => <div className="grid-table-row" role="row">{children}</div>;

export const GBody = ({children}) => <div className="grid-table-body" role="rowgroup">{children}</div>;

export const GHead = ({children}) => <div className="grid-table-head" role="rowgroup">{children}</div>;

export const GTable = ({children, className, cols}) => <div className={`grid-table not-prose overflow-hidden rounded-2xl ${className || ""}`} style={{
  "--grid-table-cols": cols
}} role="table">
    {children}
  </div>;

Use `ana login` to connect the Anaconda CLI to your account. Once you're logged in, ana uses your saved credentials for commands that need authentication.

## Log in

To log in through your browser, run:

```sh theme={null}
ana login
```

Follow the link and activation code displayed in your terminal. After you sign in, ana saves your credentials in the keyring at the following location:

<Tabs>
  <Tab title="Windows">
    `%USERPROFILE%\.anaconda\keyring`
  </Tab>

  <Tab title="macOS/Linux">
    `~/.anaconda/keyring`
  </Tab>
</Tabs>

<Note>
  If your browser does not open, open the displayed link yourself. To stop ana from opening a browser automatically, set `ANA_OPEN_BROWSER=false`.
</Note>

### Usage and options

The login command also accepts an API key and the following options:

```sh theme={null}
ana login [OPTIONS] [API_KEY]
```

**Arguments**

<GTable cols="25% 75%">
  <GHead><GRow><GTH>Argument</GTH><GTH>Description</GTH></GRow></GHead>

  <GBody>
    <GRow><GCell>`API_KEY`</GCell><GCell>Optional API key, or `-` to read a key from standard input; omit to log in through your browser</GCell></GRow>
  </GBody>
</GTable>

**Options**

<GTable cols="25% 75%">
  <GHead><GRow><GTH>Option</GTH><GTH>Description</GTH></GRow></GHead>

  <GBody>
    <GRow><GCell>`--api-key`</GCell><GCell>Prompt for an API key with hidden input instead of opening a browser</GCell></GRow>
    <GRow><GCell>`--force`</GCell><GCell>Replace existing credentials without confirmation</GCell></GRow>
    <GRow><GCell>`--help`</GCell><GCell>Show command help</GCell></GRow>
  </GBody>
</GTable>

The `ana auth login`, `ana auth logout`, and `ana auth whoami` commands are aliases of `ana login`, `ana logout`, and `ana whoami`.

### Log in with an API key

Create a key in [API key management](https://anaconda.com/app/profile/api-keys), then run:

```sh theme={null}
ana login --api-key
```

Paste your key at the prompt. Input is hidden. Using the prompt avoids leaving the key in your shell history.

### Non-interactive login for CI/CD

For automated workflows, store your API key in your CI provider's secret storage and expose it as `ANACONDA_API_KEY`. Pass the key to ana without an interactive prompt:

<Tabs>
  <Tab title="Windows PowerShell">
    ```powershell theme={null}
    $env:ANACONDA_API_KEY | ana login --force -
    ana whoami --json
    ```
  </Tab>

  <Tab title="macOS/Linux">
    ```sh theme={null}
    printf '%s\n' "$ANACONDA_API_KEY" | ana login --force -
    ana whoami --json
    ```
  </Tab>
</Tabs>

Here, `-` tells ana to read the key from standard input. `--force` replaces any credentials already saved on the runner. Omit `--force` if those credentials should be kept.

<Note>
  Setting `ANACONDA_AUTH_API_KEY` alone does not log ana in. Run the login step above before commands that need authentication. For package publishing examples, see [Anaconda GitHub Actions](/docs/cli-reference/anaconda-cli/github-actions).
</Note>

<Warning>
  Never hardcode API keys or commit them to version control. Keep the keyring file private, and do not include it in build artifacts or container images.
</Warning>

### Display your stored API key

To retrieve your saved key, run:

```sh theme={null}
ana auth api-key
```

This prints the full secret. Do not run it in an unmasked CI log or share its output.

## Display account information

To check which account you're using, run:

```sh theme={null}
ana whoami
```

For JSON output, use:

```sh theme={null}
ana whoami --json
```

## Log out

To remove your saved credentials, run:

```sh theme={null}
ana logout
```

Logout removes the credential for your current Anaconda domain from the keyring. To revoke the API key itself, follow the API key management link displayed by the command.

If you used [MCP setup](/docs/cli-reference/anaconda-cli/mcp), your AI clients have their own copies of the key. Logging out of ana does not remove those copies. Revoke the key when access should end.

## What's next

With authentication in place, you can [configure package sources](/docs/cli-reference/anaconda-cli/features) or [install additional tools](/docs/cli-reference/anaconda-cli/tools). To change the keyring location or use another Anaconda domain, see [Configuration](/docs/cli-reference/anaconda-cli/commands#configure-ana).
