﻿---
title: Connect to deployments in another Elastic Cloud organization
description: This section explains how to configure a deployment to connect remotely to clusters belonging to a different Elastic Cloud organization. Before you start,...
url: https://www.elastic.co/docs/deploy-manage/remote-clusters/ec-remote-cluster-other-ess
products:
  - Elastic Cloud Hosted
---

# Connect to deployments in another Elastic Cloud organization

This section explains how to configure a deployment to connect remotely to clusters belonging to a different Elastic Cloud organization.
<note>
  If network security policies are applied to the remote cluster, the remote cluster administrator must configure a [private connection policy of type remote cluster](https://www.elastic.co/docs/deploy-manage/security/remote-cluster-filtering), using either the organization ID or the Elasticsearch cluster ID of the local cluster as the filtering criteria. For more information, refer to [Remote clusters and network security](/docs/deploy-manage/remote-clusters#network-security).
</note>


## Allow the remote connection

Before you start, consider the security model that you would prefer to use for authenticating remote connections between clusters, and follow the corresponding steps.
<definitions>
  <definition term="API key">
    For deployments based on Elastic Stack 8.14 or later, you can use an API key to authenticate and authorize cross-cluster operations to a remote cluster. This model offers administrators of both the local and the remote deployment fine-grained access controls.
  </definition>
  <definition term="TLS certificate (deprecated in Elastic Stack 9.0.0)">
    This model uses mutual TLS authentication for cross-cluster operations. User authentication is performed on the local cluster and a user’s role names are passed to the remote cluster. A superuser on the local deployment gains total read access to the remote deployment, so it is only suitable for deployments that are in the same security domain.
  </definition>
</definitions>

<tab-set>

  <tab-item title="API key">
    API key authentication enables a local cluster to authenticate itself with a remote cluster via a [cross-cluster API key](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-cross-cluster-api-key). The API key needs to be created by an administrator of the remote cluster. The local cluster is configured to provide this API key on each request to the remote cluster. The remote cluster verifies the API key and grants access, based on the API key’s privileges.All cross-cluster requests from the local cluster are bound by the API key’s privileges, regardless of local users associated with the requests. For example, if the API key only allows read access to `my-index` on the remote cluster, even a superuser from the local cluster is limited by this constraint. This mechanism enables the remote cluster’s administrator to have full control over who can access what data with cross-cluster search and/or cross-cluster replication. The remote cluster’s administrator can be confident that no access is possible beyond what is explicitly assigned to the API key.On the local cluster side, not every local user needs to access every piece of data allowed by the API key. An administrator of the local cluster can further configure additional permission constraints on local users so each user only gets access to the necessary remote data. Note it is only possible to further reduce the permissions allowed by the API key for individual local users. It is impossible to increase the permissions to go beyond what is allowed by the API key.If you run into any issues, refer to [Troubleshooting](https://www.elastic.co/docs/troubleshoot/elasticsearch/remote-clusters).

    ### Prerequisites and limitations

    - The local and remote deployments must be on Elastic Stack 8.14 or later.
    - Contrary to the certificate security model, the API key security model does not require that both local and remote clusters trust each other.


    ### Create a cross-cluster API key on the remote deployment

    - On the deployment you will use as remote, use the [Elasticsearch API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-create-cross-cluster-api-key) or [Kibana](https://www.elastic.co/docs/deploy-manage/api-keys/elasticsearch-api-keys) to create a cross-cluster API key. Configure it with access to the indices you want to use for cross-cluster search or cross-cluster replication.
    - Copy the encoded key (`encoded` in the response) to a safe location. You will need it in the next step.


    ### Add the cross-cluster API key to the keystore of the local deploymentThe API key created previously will be used by the local deployment to authenticate with the corresponding set of permissions to the remote deployment. For that, you need to add the API key to the local deployment’s keystore.

    1. Log in to the [Elastic Cloud Console](https://cloud.elastic.co?page=docs&placement=docs-body).
    2. On the home page, find your hosted deployment and select **Manage** to access it directly. Or, select **Hosted deployments** to go to the **Hosted deployments** page to view all of your deployments.   On the **Hosted deployments** page you can narrow your deployments by name, ID, or choose from several other filters. To customize your view, use a combination of filters, or change the format from a grid to a list.
    3. From the navigation menu, select **Security**.
    4. Locate **Remote Connections > Trust management > Connections using API keys** and select **Add API key**.   
       1. Fill both fields.      
       - For the **Remote cluster name**, enter the the alias of your choice. You will use this alias to connect to the remote cluster later. It must be lowercase and only contain letters, numbers, dashes and underscores.
       - For the **Cross-cluster API key**, paste the encoded cross-cluster API key.
       2. Click **Add** to save the API key to the keystore.
    5. Restart the local deployment to reload the keystore with its new setting. To do that, go to the deployment’s main page (named after your deployment’s name), locate the **Actions** menu, and select **Restart Elasticsearch**.   
       <note>
       If the local deployment runs on version 8.14 or greater, you no longer need to perform this step because the keystore is reloaded automatically with the new API keys.
       </note>
    If you need to update the remote connection with different permissions later, refer to [Change a cross-cluster API key used for a remote connection](/docs/deploy-manage/remote-clusters/ec-edit-remove-trusted-environment#ec-edit-remove-trusted-environment-api-key).
  </tab-item>

  <tab-item title="TLS certificate (deprecated)">


    ### Specify the deployments trusted to be used as remote clustersA deployment can be configured to trust all or specific deployments in another Elastic Cloud Hosted [organization](https://www.elastic.co/docs/deploy-manage/users-roles/cloud-organization). To add cross-organization trust:

    1. From the **Security** page, select **Remote Connections > Add trusted environment** and select **Elastic Cloud**. Then click **Next**.
    2. Select **Certificates** as authentication mechanism and click **Next**.
    3. Enter the ID of the deployment’s organization which you want to establish trust with. You can find that ID on the **Organization** page. It is usually made of 10 digits.
    4. Choose one of following options to configure the level of trust with the other organization:   
       - **All deployments** - This deployment trusts all deployments in the other organization, including new deployments when they are created.
       - **Specific deployments** - Specify which of the existing deployments you want to trust in the other organization. The full Elasticsearch cluster ID must be entered for each remote cluster. The Elasticsearch `Cluster ID` can be found in the deployment overview page under **Applications**.
    5. Provide a name for the trusted environment. That name will appear in the trust summary of your deployment’s **Security** page.
    6. Select **Create trust** to complete the configuration.
    7. Repeat these steps from each of the deployments you want to use for CCS or CCR in both organizations. You will only be able to connect two deployments successfully when both of them trust each other.

    <note>
      The organization ID and cluster IDs must be entered fully and correctly. For security reasons, verification of the IDs is not possible. If cross-organization trust does not appear to be working, double-checking the IDs is a good place to start.
    </note>

    <dropdown title="Using the API">
      You can update a deployment using the appropriate trust settings for the Elasticsearch payload.In order to trust a deployment with cluster id `cf659f7fe6164d9691b284ae36811be1` (NOTE: use the Elasticsearch cluster ID, not the deployment ID) in another organization with Organization ID `1053523734`, you need to update the trust settings with an additional account like this:
      ```json
      {
        "trust":{
          "accounts":[
            {
               "account_id":"ec38dd0aa45f4a69909ca5c81c27138a",
               "trust_all":true
            },
            {
               "account_id":"1053523734",
               "trust_all":false,
               "trust_allowlist":[
                  "cf659f7fe6164d9691b284ae36811be1"
               ]
            }
          ]
        }
      }
      ```
    </dropdown>
  </tab-item>
</tab-set>

You can now connect remotely to the trusted clusters.

## Connect to the remote cluster

On the local cluster, add the remote cluster using Kibana or the Elasticsearch API.

### Using Kibana

1. Open the Kibana main menu, and select **Stack Management > Data > Remote Clusters > Add a remote cluster**.
2. Enable **Manually enter proxy address and server name**.
3. Fill in the following fields:   
   - **Name**: This *cluster alias* is a unique identifier that represents the connection to the remote cluster and is used to distinguish local and remote indices.     When using API key authentication, this alias must match the **Remote cluster name** you configured when adding the API key in the Cloud UI.
   - **Proxy address**: This value can be found on the **Security** page of the Elastic Cloud Hosted deployment you want to use as a remote.     
   <tip>
   If you’re using API keys as security model, change the port into `9443`.
   </tip>
   - **Server name**: This value can be found on the **Security** page of the Elastic Cloud Hosted deployment you want to use as a remote.     
   <note>
   If you’re having issues establishing the connection and the remote cluster is part of an Elastic Cloud Enterprise environment with a private certificate, make sure that the proxy address and server name match with the the certificate information. For more information, refer to [Administering endpoints in Elastic Cloud Enterprise](https://www.elastic.co/docs/deploy-manage/deploy/cloud-enterprise/change-endpoint-urls).
   </note>
4. Click **Next**.
5. Click **Add remote cluster** (you have already established trust in a previous step).


### Using the Elasticsearch API

To configure a deployment as a remote cluster, use the [cluster update settings API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings). Configure the following fields:
- `mode`: `proxy`
- `proxy_address`: This value can be found on the **Security** page of the Elastic Cloud Hosted deployment you want to use as a remote. Also, using the API, this value can be obtained from the Elasticsearch resource info, concatenating the field `metadata.endpoint` and port `9400` using a semicolon.  
  <tip>
  If you’re using API keys as security model, change the port into `9443`.
  </tip>
- `server_name`: This value can be found on the **Security** page of the Elastic Cloud Hosted deployment you want to use as a remote. Also, using the API, this can be obtained from the Elasticsearch resource info field `metadata.endpoint`.

This is an example of the API call to `_cluster/settings`:
```json
PUT /_cluster/settings
{
  "persistent": {
    "cluster": {
      "remote": {
        "alias-for-my-remote-cluster": {
          "mode":"proxy",
          "proxy_address": "a542184a7a7d45b88b83f95392f450ab.192.168.44.10.ip.es.io:9400",
          "server_name": "a542184a7a7d45b88b83f95392f450ab.192.168.44.10.ip.es.io"
        }
      }
    }
  }
}
```

<note>
  When using API key authentication, the cluster alias must match the one you configured when adding the API key in the Cloud UI.
</note>


### Using the Elastic Cloud RESTful API

<note>
  This section only applies if you’re using TLS certificates as cross-cluster security model and when both clusters belong to the same organization. For other scenarios, the [Elasticsearch API](#ec_using_the_elasticsearch_api_2) should be used instead.
</note>

```sh
curl -H 'Content-Type: application/json' -X PUT -H "Authorization: ApiKey $EC_API_KEY" https://api.elastic-cloud.com/api/v1/deployments/$DEPLOYMENT_ID/elasticsearch/$REF_ID/remote-clusters -d '
{
  "resources" : [
    {
      "deployment_id": "$DEPLOYMENT_ID_REMOTE",
      "elasticsearch_ref_id": "$REF_ID_REMOTE",
      "alias": "alias-your-remote",
      "skip_unavailable" : true
    }
  ]
}'
```

<definitions>
  <definition term="DEPLOYMENT_ID_REMOTE">
    The ID of your remote deployment, as shown in the Cloud UI or obtained through the API.
  </definition>
  <definition term="REF_ID_REMOTE">
    The unique ID of the Elasticsearch resources inside your remote deployment (you can obtain these values through the API).
  </definition>
</definitions>

Note the following when using the Elastic Cloud RESTful API:
1. A cluster alias must contain only letters, numbers, dashes (-), or underscores (_).
2. To learn about skipping disconnected clusters, refer to the [Elasticsearch documentation](/docs/solutions/search/cross-cluster-search#skip-unavailable-clusters).
3. When remote clusters are already configured for a deployment, the `PUT` request replaces the existing configuration with the new configuration passed. Passing an empty array of resources will remove all remote clusters.

The following API request retrieves the remote clusters configuration:
```sh
curl -X GET -H "Authorization: ApiKey $EC_API_KEY" https://api.elastic-cloud.com/api/v1/deployments/$DEPLOYMENT_ID/elasticsearch/$REF_ID/remote-clusters
```

<note>
  The response will include just the remote clusters from the same Elastic Cloud organization. In order to obtain the whole list of remote clusters, use Kibana or the [Elasticsearch API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-remote-info) directly.
</note>


## Configure roles and users

To use a remote cluster for cross-cluster replication or cross-cluster search, you need to create user roles with [remote indices privileges](/docs/deploy-manage/users-roles/cluster-or-deployment-auth/role-structure#roles-remote-indices-priv) on the local cluster. Refer to [Configure roles and users](/docs/deploy-manage/remote-clusters/remote-clusters-api-key#remote-clusters-privileges-api-key).