Complete installation guide for Elasticsearch, Kibana, and Logstash with security configuration and web interface access.
sudo su -
hostnamectl set-hostname ELK-SERVER
echo "10.75.1.100 ELK-SERVER elk" >> /etc/hosts
cat /etc/hosts
apt update
apt install gnupg2 apt-transport-https curl default-jdk vim nano git net-tools -y
ifconfig
shutdown -r now
sudo apt update -y
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | \
gpg --dearmor -o /etc/apt/trusted.gpg.d/elastic.gpg
echo "deb https://artifacts.elastic.co/packages/9.x/apt stable main" > /etc/apt/sources.list.d/elastic-9.x.list
apt update
apt install elasticsearch -y
grep -Ev '^#|^$' /etc/elasticsearch/elasticsearch.yml
echo "-Xms4g
-Xmx4g" > /etc/elasticsearch/jvm.options.d/jvm-heap.options
cp /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.bak
sed -i 's/#network.host: 192.168.0.1/network.host: 0.0.0.0/' /etc/elasticsearch/elasticsearch.yml
sed -i 's/#transport.host: 0.0.0.0/transport.host: 0.0.0.0/' /etc/elasticsearch/elasticsearch.yml
systemctl daemon-reload
systemctl enable --now elasticsearch
systemctl start elasticsearch
systemctl status elasticsearch
# Verify ports
ss -altnp | grep -E "9200|9300"
/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
curl https://ELK-SERVER:9200 --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:abcd@1234
tail -f /var/log/elasticsearch/elasticsearch.log
apt install kibana -y
cp /etc/kibana/kibana.yml /etc/kibana/kibana_backup.yml
sed -i 's/#server.port: 5601/server.port: 5601/' /etc/kibana/kibana.yml
sed -i 's/#server.host: "localhost"/server.host: "0.0.0.0"/' /etc/kibana/kibana.yml
/usr/share/kibana/bin/kibana-encryption-keys generate
echo -e "xpack.encryptedSavedObjects.encryptionKey: a4478a7b06851c9ade28d49dee092733
xpack.reporting.encryptionKey: 01e570c2a747d5af721a54db9462fe51
xpack.security.encryptionKey: 7dd0a309e7818cf32fabf74ae108118b" >> /etc/kibana/kibana.yml
# Verify
grep -Ev '^#|^$' /etc/kibana/kibana.yml
systemctl daemon-reload
systemctl enable --now kibana
systemctl start kibana
systemctl status kibana
# Verify port
ss -altnp | grep 5601
/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
/usr/share/kibana/bin/kibana-verification-code
apt install logstash -y
# Extract Elasticsearch CA certificate
cd /etc/elasticsearch/certs/
openssl s_client -showcerts -connect ELK-SERVER:9200 </dev/null 2>/dev/null \
| openssl x509 > /etc/logstash/elasticsearch-ca.crt
# Start service
systemctl daemon-reload
systemctl enable --now logstash
systemctl start logstash
systemctl status logstash
# Monitor logs
tail -f /var/log/logstash/logstash-plain.log
# Verify port
ss -altnp | grep 5044