Back to the list of posts

Настройка авторизации ElasticSearch на сервере Ubuntu

ElasticSearch is a powerful and fast search engine that can be used to process large amounts of data. In this article, we will look at how to set up authorization in ElasticSearch on an Ubuntu server.

Install Java

Java must be installed before installing ElasticSearch. To do this, run the following commands:


sudo apt update
sudo apt install default jdk

Installing ElasticSearch

After Java is installed, you can start installing ElasticSearch. To do this, run the following commands:


wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt update
sudo apt install elasticsearch

Authorization settings
Creating users

To set up authorization in ElasticSearch, you need to create users and assign them the appropriate roles. To create a user, run the following command:


sudo /usr/share/elasticsearch/bin/elasticsearch-users useradd  -p  -r 

Replace , and with your desired values.

Setting up roles

To set up roles, follow these steps:

Open the ElasticSearch configuration file:


sudo nano /etc/elasticsearch/elasticsearch.yml

Add the following lines to the file:


xpack.security.enabled: true
xpack.security.authc:
   realms:
     native:
       native1:
         order: 0

Create a roles.yml file:


sudo nano /etc/elasticsearch/roles.yml

Add the roles and their permissions to the file. For example:


read_only:
   cluster:
     - 'monitor'
   indices:
     - names: '*'
       privileges:
         - 'read'
         - 'view_index_metadata'

Restart ElasticSearch

After setting authorization, you need to restart ElasticSearch:


sudo systemctl restart elasticsearch

Conclusion

In this article, we looked at how to set up authorization in ElasticSearch on an Ubuntu server. This will protect your search engine and prevent unauthorized access to your data.

#DevOps #Search #Elasticsearch

Back to the list of posts Next post

menuclose

start a project

Заявка отправлена

Спасибо! Заявка отправлена. Свяжемся с вами в течении часа!