<a id="remotes"></a>

# How to add remote servers

#### NOTE
Remote servers are a concept in the LXD CLI.

If you are using the UI or the API, you can interact with different remotes by using their exposed UI or API addresses instead.

By default, the command-line client interacts with the local LXD daemon, but you can add other servers or clusters to interact with.

One use case for remote servers is to distribute images that can be used to create instances on local servers.
See [Remote image servers](https://canonical.com/lxd/docs/default/reference/remote_image_servers/index.html.md#remote-image-servers) for more information.

You can also add a full LXD server as a remote server to your client.
In this case, you can interact with the remote server in the same way as with your local daemon.
For example, you can manage instances or update the server configuration on the remote server.

## Authentication

To be able to add a LXD server as a remote server, the server’s API must be exposed, which means that its [`core.https_address`](https://canonical.com/lxd/docs/default/server/index.html.md#server-core:core.https_address) server configuration option must be set.

When adding the server, you must then authenticate with it using the chosen method for [Remote API authentication](https://canonical.com/lxd/docs/default/authentication/index.html.md#authentication).

See [How to expose LXD to the network](https://canonical.com/lxd/docs/default/howto/server_expose/index.html.md#server-expose) for more information.

## List configured remotes

<!-- Include parts of the content from file [howto/images_remote.md](howto/images_remote.md) -->

To see all configured remote servers, enter the following command:

```none
lxc remote list
```

Remote servers that use the [simple streams format](https://git.launchpad.net/simplestreams/tree/) are pure image servers.
Servers that use the `lxd` format are LXD servers, which either serve solely as image servers or might provide some images in addition to serving as regular LXD servers.
See [Remote server types](https://canonical.com/lxd/docs/default/reference/remote_image_servers/index.html.md#remote-image-server-types) for more information.

## Add a remote LXD server

<!-- Include parts of the content from file [howto/images_remote.md](howto/images_remote.md) -->

To add a LXD server as a remote, enter the following command:

```none
lxc remote add <remote_name> <IP|FQDN|URL|token> [flags]
```

Some authentication methods require specific flags (for example, use [`lxc remote add <remote_name> <IP|FQDN|URL> --auth-type=oidc`](https://canonical.com/lxd/docs/default/reference/manpages/lxc/remote/add/index.html.md#lxc-remote-add-md) for OIDC authentication).
See [Authenticate with the LXD server](https://canonical.com/lxd/docs/default/howto/server_expose/index.html.md#server-authenticate) and [Remote API authentication](https://canonical.com/lxd/docs/default/authentication/index.html.md#authentication) for more information.

For example, enter the following command to add a remote through an IP address:

```none
lxc remote add my-remote 192.0.2.10
```

You are prompted to confirm the remote server fingerprint and then asked for the password or token, depending on the authentication method used by the remote.

## Select a default remote

The LXD command-line client is pre-configured with the `local` remote, which is the local LXD daemon.

To select a different remote as the default remote, enter the following command:

```none
lxc remote switch <remote_name>
```

To see which server is configured as the default remote, enter the following command:

```none
lxc remote get-default
```

## Configure a global remote

You can configure remotes on a global, per-system basis.
These remotes are available for every user of the LXD server for which you add the configuration.

Users can override these system remotes (for example, by running [`lxc remote rename`](https://canonical.com/lxd/docs/default/reference/manpages/lxc/remote/rename/index.html.md#lxc-remote-rename-md) or [`lxc remote set-url`](https://canonical.com/lxd/docs/default/reference/manpages/lxc/remote/set-url/index.html.md#lxc-remote-set-url-md)), which results in the remote and its associated certificates being copied to the user configuration.

To configure a global remote, edit the `config.yml` file that is located in one of the following directories:

- the directory specified by `LXD_GLOBAL_CONF` (if defined)
- `/var/snap/lxd/common/global-conf/` (if you use the snap)
- `/etc/lxd/` (otherwise)

Certificates for the remotes must be stored in the `servercerts` directory in the same location (for example, `/etc/lxd/servercerts/`).
They must match the remote name (for example, `foo.crt`).

See the following example configuration:

```default
remotes:
  foo:
    addr: https://192.0.2.4:8443
    auth_type: tls
    project: default
    protocol: lxd
    public: false
  bar:
    addr: https://192.0.2.5:8443
    auth_type: tls
    project: default
    protocol: lxd
    public: false
```
