File-based user authenticationedit

You can manage and authenticate users with the built-in file realm. With the file realm, users are defined in local files on each node in the cluster.

As the administrator of the cluster, it is your responsibility to ensure the same users are defined on every node in the cluster. The Elastic Stack security features do not deliver any mechanism to guarantee this.

The file realm is primarily supported to serve as a fallback/recovery realm. It is mostly useful in situations where all users locked themselves out of the system (no one remembers their username/password). In this type of scenarios, the file realm is your only way out - you can define a new admin user in the file realm and use it to log in and reset the credentials of all other users.

When you configure realms in elasticsearch.yml, only the realms you specify are used for authentication. To use the file realm as a fallback, you must include it in the realm chain.

To define users, the security features provide the users command-line tool. This tool enables you to add and remove users, assign user roles, and manage user passwords.

Configuring a file realmedit

All the data about the users for the file realm is stored in two files on each node in the cluster: users and users_roles. Both files are located in ES_PATH_CONF and are read on startup.

The users and users_roles files are managed locally by the node and are not managed globally by the cluster. This means that with a typical multi-node cluster, the exact same changes need to be applied on each and every node in the cluster.

A safer approach would be to apply the change on one of the nodes and have the files distributed or copied to all other nodes in the cluster (either manually or using a configuration management system such as Puppet or Chef).

The file realm is added to the realm chain by default. You don’t need to explicitly configure a file realm.

  1. (Optional) Add a realm configuration to elasticsearch.yml under the namespace. At a minimum, you must set the realm’s order attribute.

    For example, the following snippet shows a file realm configuration that sets the order to zero so the realm is checked first:

                order: 0
  2. Restart Elasticsearch.
  3. Add user information to the ES_PATH_CONF/users file on each node in the cluster.

    The users file stores all the users and their passwords. Each line in the file represents a single user entry consisting of the username and hashed and salted password.


    To limit exposure to credential theft and mitigate credential compromise, the file realm stores passwords and caches user credentials according to security best practices. By default, a hashed version of user credentials is stored in memory, using a salted sha-256 hash algorithm and a hashed version of passwords is stored on disk salted and hashed with the bcrypt hash algorithm. To use different hash algorithms, see User cache and password hash algorithms.

    While it is possible to modify the users files directly using any standard text editor, we strongly recommend using the elasticsearch-users tool to apply the required changes.

    As the administrator of the cluster, it is your responsibility to ensure the same users are defined on every node in the cluster. The Elasticsearch security features do not deliver any mechanisms to guarantee this.

  4. Add role information to the ES_PATH_CONF/users_roles file on each node in the cluster.

    The users_roles file stores the roles associated with the users. For example:


    Each row maps a role to a comma-separated list of all the users that are associated with that role.

    You can use the elasticsearch-users tool to update this file. You must ensure that the same changes are made on every node in the cluster.

  5. (Optional) Change how often the users and users_roles files are checked.

    By default, Elasticsearch checks these files for changes every 5 seconds. You can change this default behavior by changing the resource.reload.interval.high setting in the elasticsearch.yml file (as this is a common setting in Elasticsearch, changing its value may effect other schedules in the system).