Set up minimal security for Elasticsearchedit

You enable the Elasticsearch security features and then create passwords for built-in users. You can add more users later, but using the built-in users simplifies the process of enabling security for your cluster.

Prerequisitesedit

  1. Install and configure Elasticsearch and Kibana. See Getting started with the Elastic Stack.
  2. Verify that you are using a license that includes the specific security features you want.

    The basic license includes minimal security settings for the Elastic Stack, so you can just download the distribution and get to work. You can also enable a free trial license to access all features of the Elastic Stack. See subscriptions and license management.

Enable Elasticsearch security featuresedit

When you use the basic license, the Elasticsearch security features are disabled by default. Enabling the Elasticsearch security features enables basic authentication so that you can run a local cluster with username and password authentication.

  1. Stop both Kibana and Elasticsearch if they are running.
  2. Add the xpack.security.enabled setting to the ES_PATH_CONF/elasticsearch.yml file and set the value to true:

    xpack.security.enabled: true

    The ES_PATH_CONF variable is the path for the Elasticsearch configuration files. If you installed Elasticsearch using archive distributions (zip or tar.gz), the variable defaults to ES_HOME/config. If you used package distributions (Debian or RPM), the variable defaults to /etc/elasticsearch.

Create passwords for built-in usersedit

To communicate with the cluster, you must configure a username for the built-in users. Unless you enable anonymous access, all requests that don’t include a user name and password are rejected.

You only need to set passwords for the elastic and kibana_system users when enabling minimal or basic security.

  1. Start Elasticsearch. For example, if you installed Elasticsearch with a .tar.gz package, run the following command from the Elasticsearch directory:

    ./bin/elasticsearch
  2. In another terminal window, set the passwords for the built-in users by running the elasticsearch-setup-passwords utility. Using the auto parameter outputs randomly-generated passwords to the console that you can change later if necessary:

    ./bin/elasticsearch-setup-passwords auto

    If you want to use your own passwords, run the command with the interactive parameter instead of the auto parameter. Using this mode steps you through password configuration for all of the built-in users.

    ./bin/elasticsearch-setup-passwords interactive
  3. Save the generated passwords. You’ll need them to add the built-in user to Kibana.

After you set a password for the elastic user, you cannot run the elasticsearch-setup-passwords command a second time.

Next: Configure Kibana to connect to Elasticsearch with a password

Configure Kibana to connect to Elasticsearch with a passwordedit

When the Elasticsearch security features are enabled, users must log in to Kibana with a valid username and password.

Kibana also performs some background tasks that require use of the built-in elastic user.

You’ll configure Kibana to use the built-in elastic user and the password that you created earlier.

  1. Add the elasticsearch.username setting to the KIB_PATH_CONF/kibana.yml file and set the value to the elastic user:

    elasticsearch.username: "elastic"

    The KIB_PATH_CONF variable is the path for the Kibana configuration files. If you installed Kibana using archive distributions (zip or tar.gz), the variable defaults to KIB_HOME/config. If you used package distributions (Debian or RPM), the variable defaults to /etc/kibana.

  2. From the directory where you installed Kibana, run the following commands to create the Kibana keystore and add the secure settings:

    1. Create the Kibana keystore:

      ./bin/kibana-keystore create
    2. Add the password for the elastic user to the Kibana keystore:

      ./bin/kibana-keystore add elasticsearch.password

      When prompted, enter the password for the elastic user.

  3. Restart Kibana. For example, if you installed Kibana with a .tar.gz package, run the following command from the Kibana directory:

    ./bin/kibana
  4. Log in to Kibana as the elastic user.

What’s next?edit

Congratulations! You enabled password protection for your local cluster to prevent unauthorized access. You can log in to Kibana securely as the elastic user.

To add another layer of security, Set up basic security for the Elastic Stack. You’ll configure Transport Layer Security (TLS) to secure all internal communication between nodes in your cluster.