How to setup Elasticsearch+Kibana and enable Authentication in Ubuntu 20.04

Prerequisites

  • OS: Ubuntu 20.04
  • User account with root privileges

Step 1: Install Java 8

sudo apt-get update && sudo apt-get install openjdk-8-jdk -y
java --version

Step2: Install Elasticsearch

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install elasticsearch -y
sudo vi /etc/elasticsearch/elasticsearch.yml
cluster.name: my-elk-stack #To change elasticsearch cluster namenetwork.host: 0.0.0.0 #set 0.0.0.0 to listen on all network interface or you can restrict to specific network interfacediscovery.type: single-node #for single node cluster or testing env. NOT RECOMMENDED IN PRODUCTION.#below options are for enable Auth in elasticsearch. if you don't want to enable Auth, ignore below configurationxpack.security.enabled: true 
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /etc/elasticsearch/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /etc/elasticsearch/elastic-certificates.p12
sudo /usr/share/elasticsearch/bin/elasticsearch-certutil cert -out elastic-certificates.p12 -pass ""
sudo cp /usr/share/elasticsearch/elastic-certificates.p12 /etc/elasticsearch/elastic-certificates.p12sudo chown elasticsearch: /etc/elasticsearch/elastic-certificates.p12
sudo vi /etc/elasticsearch/jvm.options
-Xmx2g 
-Xms2g
sudo systemctl restart elasticsearch.service
sudo systemctl status elasticsearch.service
sudo systemctl enable elasticsearch.service
sudo /usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto
curl http://username:password@localhost:9200/_cluster/health?pretty

OUTPUT:

check elasticsearch status

Step 3: Install Kibana

sudo apt-get install kibana -y
sudo vi /etc/kibana/kibana.yml
server.port: 5601 #port on which kibana listenserver.host: "0.0.0.0" #set 0.0.0.0 to listen on all network interface or you can restrict to specific network interfaceelasticsearch.hosts: ["http://localhost:9200"] #elasticsearch address.elasticsearch.username: "kibana_user" #kibana user to connect with elasticsearchelasticsearch.password: "passworod" #enter passowrd generated by elasticsearch-setup-passwords tool
sudo systemctl start kibana
sudo systemctl enable kibana
http://localhost:5601/

--

--

--

DevOps Engineer, Linux lover, Technology and Automation enthusiast. A strong believer in continuous learning.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Satisfaction of the Developers related to Jobs

Recipe OSS: How to modify the object storage class? (Alibaba Cloud)

Deployment of Shiny RMarkdown on EC2

Hacking at Y Combinator…without code

HP ZBook 15 G6 Intel Core i7–9850H 16GB 512GB SSD NVIDIA Quadro T1000 Warranty

The Valuable Github Repositories for Tech Geeks — Front End, UX/UI

Setting Up Networking For An Ubuntu 16.10 Server in VirtualBox

Connect Azure Databricks to CosmosDB Gremlin API and run queries

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sujit Patel

Sujit Patel

DevOps Engineer, Linux lover, Technology and Automation enthusiast. A strong believer in continuous learning.

More from Medium

Docker for devs with hands-on| Part-5

Docker/Container Introduction

Docker-compose + NGINX + TLS Certificates

Nginx server error