---
title: "The CLI connect command"
slug: "the-cli-connect-command"
abstract: "Connect to another environment and use its authentication credentials"
---
# The CLI connect command

The CLI `connect` command helps connect your environment to another existing environment. After the connection, your environment uses login information from the reference/base environment and can override the `host` and `alloWrite` properties.

## Usage

The structure for the Sitecore CLI `environment` command is:

```shell
dotnet sitecore connect [options]

```

## Options

You can use the following options with the `connect` command:

| Option | Description |
| --- | --- |
| `-n`, `--environment-name` | Required.<br><br>Named Sitecore environment to use. |
| `--cm` | Required.<br><br>Sitecore content management hostname to connect to. |
| `-r, --ref` | Required.<br><br>Reference to base environment. |
| `-c, --config` | Path to root sitecore.config directory (default: cwd). |
| `--allow-write` | Enables writing data to the environment. |
| `-t, --trace` | Write more additional diagnostic and performance data. |
| `-?, -h, --help` | Show help and usage information. |

## Examples

To use the connect command, you must provide the values for the options `--environment-name`, `--cm`, and `--ref`. For example:

```shell
dotnet sitecore connect --cm https://hostname --environment-name newEnv --ref default

```

If the operation is successful, the command prints out:

```shell
Environment 'newEnv' has been connected to 'default' environment

```