Would you like to learn how to use the ElasticSearch Token-based authentication? In this tutorial, we are going to show you how to create an Elasticsearch authentication token and use the token to perform queries to the ElasticSearch server.

• Ubuntu 18
• Ubuntu 19
• ElasticSearch 7.6.2

In our example, The ElastiSearch server IP address is 192.168.100.7.

Tutorial ElasticSearch – Authentication Token

Install the required packages.

Copy to Clipboard

Test your communication with the ElasticSearch server.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Keep in mind that the token-based authentication requires an HTTPS connection to ElasticSearch.

To enable the Token-based authentication, you need to create a certificate and enable the following features on the Elasticsearch configuration file.

Copy to Clipboard

Create an ElasticSearch token.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

In our example, we created an authentication token to the user account named: Elastic.

• Token: y/auAxZjVXlhQ090bFRLdXBSR1ZlV1Q2ckNR

The token is valid for 1200 seconds.

Important! We used the HTTPS protocol instead of the HTTP. 

Use the token to perform a query to the ElasticSearch server.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Congratulations! You are able to use an ElasticSearch token for authentication.