Authentication to ElasticSearch using the custom readonlyrest plugin.
To add the user follow the below steps:
Prerequisites
Download Readonlyrest Plugin, to download:
- Go to https://readonlyrest.com/download
- Select Product Elasticsearch plugin (Free).
- Elastic Stack Version 6.4.2
- Send to email email-id.
- Click Get It Now
- Download link is sent to the mentioned email.
Installing readonlyrest plugin:
/path to elastic search/bin/elasticsearch-plugin install
file:///path to readonlyrest-<version>.zip
Example: /usr/share/elasticsearch/bin/elasticsearch-plugin install file:///root/readonlyrest-1.16.28_es6.4.2..zip
Procedure
Example
readonlyrest: access_control_rules: - name: Accept GET,POST requests from user auth_key_unix: Test: $6$rounds=65635$koKSfnyc$4iZfsoA9mxZYcRMSXUylDa2T/mPWnh/WWNqI7lM. 2hdXCIx5cVJY0Ni5NrBUXPc5F8xSVYGvs7ORVzAoyJeXq/
For Hashing of password:
./encryptpassword.py <password>
Creating encryptpassword.py file:
- Go to https://github.com/beshu-tech/readonlyrest-docs/blob/master/elasticsearch.md#rules
- Copy and write the code to file using the command:
vi encryptpassword.py
Paste the code and save the file using :wq.
- Change the permission on the file encryptpassword.py
chmod 755 encryptpassword.py
- Execute encryptpassword.py.
./encryptpassword.py <password>
Note: Authentication must be enabled in each elastic search instance in the cluster.