---
name: databases-for-elasticsearch-howto-user-management
title: Managing users and roles
description: Databases for Elasticsearch deployments come with authentication enabled and use Elasticsearch's Built-in users.
last-updated: 2024-12-09
---

> ## Documentation Index
> The table of contents for this documentation set is at https://cloud.ibm.com/docs/databases-for-elasticsearch?format=markdown
> The index for all IBM Cloud docs is at: https://cloud.ibm.com/docs/llms.txt
> Use these files to discover more information as needed.

# Managing users and roles
{: #user-management}

Databases for Elasticsearch deployments come with authentication enabled and use Elasticsearch's [Built-in users](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/built-in-users.html){: external}.

Add users in the UI on the _Service credentials_ page, with the [Cloud Databases CLI plug-in](https://cloud.ibm.com/docs/databases-cli-plugin?topic=databases-cli-plugin-cdb-reference&format=markdown#users), or the [Cloud Databases API](https://cloud.ibm.com/apidocs/cloud-databases-api/cloud-databases-api-v5#createdatabaseuser).

## The admin user
{: #user-management-admin-user}

When you provision a Databases for Elasticsearch deployment, an `admin` user is automatically created. 

Set the admin password before using it to connect.
{: important}

### Setting the Admin password in the UI
{: #user-management-set-admin-password-ui}
{: ui}

Set your Admin password through the UI by selecting your instance from the [Resource list](https://cloud.ibm.com/resources){: external}. On the dashboard, select the **Settings** tab, then either enter or generate a new admin password and click the *Change password* button.

### Setting the Admin password in the CLI
{: #user-management-set-admin-password-cli}
{: cli}

Use the `cdb user-password` command from the IBM Cloud CLI Cloud Databases plug-in to set the admin password.

For example, to set the admin password for a deployment named `example-deployment`, use the following command:

```sh
ibmcloud cdb user-password example-deployment admin <newpassword>
```
{: pre}

### Setting the Admin password in the API
{: #user-management-set-admin-password-api}
{: api}

The *Foundation endpoint* that is shown on the *Overview* panel in the Deployment details section of your service provides the base URL to access this deployment through the API. Use it with the [Set specified user's password](https://cloud.ibm.com/apidocs/cloud-databases-api/cloud-databases-api-v5#updateuser){: external} endpoint to set the admin password.

```sh
curl -X PATCH `https://api.{region}.databases.cloud.ibm.com/v5/ibm/deployments/{id}/users/admin` \
-H `Authorization: Bearer <>` \
-H `Content-Type: application/json` \ 
-d `{"password":"newrootpasswordsupersecure21"}` \
```
{: pre}

## The `ibm_superuser` role
{: #user-management-elasticsearch-ibm-superuser}

For Elasticsearch versions 7.17.7 and later, all users, both new and existing, including the `admin` user, will be assigned the `ibm_superuser` role. The `ibm_superuser` role has the same privileges as `superuser`, except the `ibm_superuser` role cannot access hidden, internal, or restricted indexes. Restricting access to hidden indexes prevents users from inadvertently limiting their own access by closing security indexes.

While you have the permissions to change this role back to the original `superuser`, you should not do so. Changing `ibm_superuser` to `superuser` will disrupt your access to your Elasticsearch deployment.
{: important}

## Managing users and roles through the UI
{: #user-management-ui}
{: ui}

1. Go to the service dashboard for your service.
2. Click **Service credentials** to open the page.
3. Click **New credential**.
4. Choose a descriptive name for your new credential. 
5. (Optional) Specify whether the new credentials use a public or private endpoint. Use either `{ "service-endpoints": "public" }` / `{ "service-endpoints": "private" }` in the *Add Inline Configuration Parameters* field to generate connection strings that use the specified endpoint. Use of the endpoint is not enforced. It just controls which hostnames are in the connection strings. Public endpoints are generated by default.
6. Click **Add** to provision the new credentials. A username and password, and an associated Elasticsearch user is auto-generated.

The new credentials appear in the table, and the connection strings are available as JSON in a click-to-copy field under _View credentials_.

Creating a user from the CLI or API doesn't automatically populate that user's connection strings into _Service credentials_. If you want to add them there, you can create a new credential with the existing user information. Enter the username and password in the JSON field under _Add Inline Configuration Parameters_. For example, `{"existing_credentials":{"username":"Robert","password":"supersecure"}}`. Basically, you send in the username and password, and _Service credentials_ generates the connection strings with the credentials filled in.

Generating credentials from an existing user does not check for or create that user. 
{: .tip}

If you need users that are created from _Service credentials_ to have a different role, use the`admin` user to change their role.

## Managing users and roles through the CLI
{: #user-management-cli}
{: cli}

If you need users to have a different role, you can use the `admin` user to change their role.

Users that are created directly from the CLI do not appear in _Service credentials_, but you can add them.

If you manage your service through the [Cloud Databases CLI plug-in](https://cloud.ibm.com/docs/cli?topic=cli-install-ibmcloud-cli&format=markdown), create a new user with `cdb user-create`. For example, to create a new user for a deployment named `example-deployment`, use the following command:

```sh
ibmcloud cdb user-create example-deployment <newusername> <newpassword>
```
{: pre}

When the task finishes, retrieve the new user's connection strings with the [`ibmcloud cdb deployment-connections`](https://cloud.ibm.com/docs/databases-cli-plugin?topic=databases-cli-plugin-cdb-reference&format=markdown#deployment-connections){: external} command, which looks like:

```sh
ibmcloud cdb deployment-connections [--user <userid>] [--password <password>] [--endpoint-type <endpoint type>] [--all] [--only] [--start] [--certroot <path>] [--json]
```
{: pre}

## Managing users and roles through the API
{: #user-management-api}
{: api}

If you need users to have a different role, use the admin user to change their role.

Users that are created directly from the API do not appear in _Service credentials_, but you can add them.

The _Foundation endpoint_ that is shown on the _Overview_ section of your service provides the base URL to access this deployment through the API. To create and manage users, use the base URL with the [`/users` endpoint](https://cloud.ibm.com/apidocs/cloud-databases-api/cloud-databases-api-v5#createdatabaseuser).

The command looks like: 

```sh
curl -X POST 'https://api.{region}.databases.cloud.ibm.com/v4/ibm/deployments/{id}/users' \
-H "Authorization: Bearer $APIKEY" \
-H "Content-Type: application/json" \
-d '{"username":"jane_smith", "password":"newsupersecurepassword"}'
```
{: pre}

To retrieve a user's connection strings, use the base URL with the `/users/{userid}/connections` endpoint. 

## Elasticsearch-created users and roles
{: #user-management-elasticsearch-users}

If the built-in users and roles do not suit your environment, [create users and roles](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/users-command.html){: external} directly in Elasticsearch. The admin user for your deployment has the power to create any role or set of privileges for use on your deployment.