Would you like to learn how to use the ElasticSearch authentication using an API? In this tutorial, we are going to show you how to create an API and use it 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.
ElasticSearch Related Tutorial:
On this page, we offer quick access to a list of tutorials related to ElasticSearch installation.
Tutorial ElasticSearch – Authentication API
Install the required packages.
Test your communication with the ElasticSearch server.
Here is the command output:
Keep in mind that the API based authentication requires an HTTPS connection to ElasticSearch.
To enable the API based authentication, you need to create a certificate and enable the following features on the Elasticsearch configuration file.
Create an ElasticSearch API.
Here is the command output:
In our example, we created an authentication API to the user account named: Elastic.
• API ID – l1YNpHEB5GTDEAepLnnx
• API KEY – 40kYGW-SRZG2KnL_dWkBSQ
Important! We used the HTTPS protocol instead of the HTTP.
We need to encode the ID and KEY using Base64.
• API ID – l1YNpHEB5GTDEAepLnnx
• API KEY – 40kYGW-SRZG2KnL_dWkBSQ
Important! You need to separate the ID and KEY using the colon character.
Here is the command output:
Use the API to perform a query to the ElasticSearch server.
Here is the command output:
Use the API to perform a query to the ElasticSearch server with verbose.
Here is the command output:
Congratulations! You are able to use an ElasticSearch API for authentication.