> This page location: /docs.md > /docs/tools-and-connectors.md > /docs/atlas/cli/current.md

> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

<!--
Tab options on this page. Append to the .md URL to filter:
  ?tabs=<id,...>   select specific tabs (e.g. ?tabs=nodejs,shell)
  ?allTabs=true    include every tab
  (no param)       default: one tab per tabset

Available tabs:
  other tabs: user-account, service-account, api-keys
-->

# Connect from the Atlas CLI

## Select a Connection Method

When you connect to an existing Atlas account from the Atlas CLI, you can authenticate with one of the following options for the `atlas auth login` command:

| Option | Authentication Method | Use Case |
| --- | --- | --- |
| `UserAccount` | Atlas login credentials and an authentication token | Best for non-programmatic use |
| `ServiceAccount` | Service Account | Best for programmatic use with a Service Account |
| `APIKeys` | API (Application Programming Interface) keys | Best for programmatic use with an API Key |

**Important:**

For Atlas CLI versions before 1.47, API (Application Programming Interface) keys are stored in plaintext in the Atlas CLI configuration file. Your API (Application Programming Interface) keys are like passwords. Ensure that you secure the configuration file appropriately. Atlas CLI 1.47+ attempts to store credentials securely.

To create a new Atlas account or onboard an existing account that doesn't have any clusters, see [Get Started with Atlas.](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-getting-started.md#std-label-atlas-cli-onboarding)

Select a use case below to learn more about the available connection options:

### Non-programmatic Use

Use the `atlas auth login` command with the `UserAccount` option to authenticate with your Atlas login credentials and a one-time authentication token. The `UserAccount` option requires manual login and verification of an authentication token, which is valid for 12 hours. API (Application Programming Interface) keys are optional when connecting with the `UserAccount` option.

After you run `atlas auth login` with the `UserAccount` option, you can:

- [Connect with minimum required settings](https://www.mongodb.com/docs/atlas/cli/current/connect-atlas-cli.md#std-label-skip-profile-setup) and specify the `--projectId` and `--orgId` flags with each command. This is the quickest way to get started for first-time login.

- Save your connection settings in a [profile](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-save-connection-settings.md#std-label-atlas-cli-profiles). [Profiles](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-save-connection-settings.md#std-label-atlas-cli-profiles) store the project IDs, organization IDs, and, optionally, API (Application Programming Interface) keys to use in future Atlas CLI sessions. To save time, you can specify a profile instead of using the `--projectId` and `--orgId` flags with each command.

## Connect With Minimum Required Settings

Select a use case and follow the steps to connect from the Atlas CLI with minimum required settings.

### Complete the Prerequisites

### Non-programmatic Use

- [Install the Atlas CLI.](https://www.mongodb.com/docs/atlas/cli/current/install-atlas-cli.md#std-label-install-atlas-cli)

- Add your host's IP address to the [IP access list.](https://www.mongodb.com/docs/atlas/security/ip-access-list.md#std-label-access-list)

  If you authenticate with your Atlas user credentials and your organization's owners enable [IP access list for the Atlas UI for an organization](https://www.mongodb.com/docs/atlas/tutorial/manage-organizations/#require-ip-access-list-for-the-atlas-ui), your IP address must be added to the IP access list to run commands in this organization. To learn more, see [Require IP Access List for the Atlas UI.](https://www.mongodb.com/docs/atlas/tutorial/manage-organizations/#require-ip-access-list-for-the-atlas-ui)

### Follow These Steps

Select a use case and follow the procedure to quickly connect from the Atlas CLI.

### Non-programmatic Use

1. Run the authentication command.

   Run the `atlas auth login` command in your terminal.

   ```sh
   atlas auth login
   ```

   The command opens a browser window and returns a one-time activation code. This code expires after 10 minutes.

2. Select the `UserAccount` option and press `Enter`.

3. Sign into Atlas.

   If you aren't signed in already, sign into your Atlas account in the browser.

4. Enter the authorization code.

   Paste your activation code into the browser and click Confirm Authorization.

5. Return to the Atlas CLI and accept the default profile options.

   Return to the terminal. If you connect successfully, you see a message:

   `Successfully logged in as {Your Email Address}.`

   Accept the default profile configuration by pressing Enter if the following options display:

   - `Default Org ID`

   - `Default Project ID`

   - `Default Output Format`

   - `Default MongoDB Shell Path`

   **Important:**

   If you previously set up any profiles with API (Application Programming Interface) keys for MongoCLI, your profiles [migrate automatically](https://www.mongodb.com/docs/atlas/cli/current/migrate-to-atlas-cli.md#std-label-migrate-to-atlas-cli). Some migrated profiles might cause Atlas CLI commands to fail when authenticating with `atlas auth login`. The following message displays when you run `atlas auth login` if there is a conflict:

   ```text
   There was an error fetching your organizations: Global user is
   from outside access listed subnets.
   ```

   To fix the conflict, open the [configuration file](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-save-connection-settings.md#std-label-config-toml-location), remove the default profile, and run `atlas auth login` again.

6. Issue commands using the `--projectId` and `--orgId` flags.

   When you run [Atlas CLI commands](https://www.mongodb.com/docs/atlas/cli/current/command/atlas.md#std-label-atlas) for the duration of your Atlas CLI session, specify your Project ID and Org ID using the `--projectId` and `--orgId` flags.

   **Example:**

   ```sh
   atlas alerts list --projectId 60b3c81153cf986293e2608b
   ```

## Take the Next Steps

Start using the [Atlas CLI commands.](https://www.mongodb.com/docs/atlas/cli/current/command/atlas.md#std-label-atlas)

To save connection settings by modifying the default profile or create a different profile, see [Save Connection Settings.](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-save-connection-settings.md#std-label-atlas-cli-profiles)
