Dans cet article, je vais vous montrer comment installer Elastic, une solution de SIEM (Security Information and Event Management) développée par Elastic NV. Un SIEM est une plateforme de cybersécurité qui centralise et analyse les journaux et événements provenant de multiples appareils d'un réseau, permettant ainsi la détection d'activités anormales et la génération d'alertes en temps réel.
Nous allons installer la solution complète Elastic, qui comprend Elasticsearch et Kibana, sur un serveur Debian déployé en local (on-premises) — ce qui signifie qu'aucune licence payante n'est requise pour une utilisation de base. Cependant, je recommande toujours aux entreprises de souscrire à une licence commerciale afin de bénéficier d'un support complet et de fonctionnalités supplémentaires. J'avais précédemment publié un article concernant l'installation de Elastic Stack version 8 (disponible ici), et avec la sortie de la version 9, je saisis cette opportunité pour mettre à jour ce guide.
Elasticsearch est un moteur de stockage, de recherche et d'analyse distribué et en temps réel.
Kibana est une plateforme d'analyse et de visualisation open source conçue pour fonctionner avec Elasticsearch. Kibana sera utilisé pour rechercher, visualiser et interagir avec les données stockées dans les index Elasticsearch.
root@host:~# apt update && apt install apt-transport-https gnupg curl wget
root@host:~# wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
root@host:~# echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/9.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-9.x.list
root@host:~# apt update && apt install elasticsearch
[…]
--------------------------- Security autoconfiguration information ------------------------------
Authentication and authorization are enabled.
TLS for the transport and HTTP layers is enabled and configured.
The generated password for the elastic built-in superuser is : elastic_password;)
If this node should join an existing cluster, you can reconfigure this with
'/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here>
after creating an enrollment token on your existing cluster.
You can complete the following actions at any time:
Reset the password of the elastic built-in superuser with
'/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'.
Generate an enrollment token for Kibana instances with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'.
Generate an enrollment token for Elasticsearch nodes with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'.
-------------------------------------------------------------------------------------------------
root@host:~# apt update && apt install kibana
network.host: 0.0.0.0
root@host:~# systemctl start elasticsearch.service
root@host:~# curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200
Enter host password for user 'elastic': elastic_password;)
{
"name" : "std",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "StdgreaTBanDKphU4S0ceg",
"version" : {
"number" : "9.0.0",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "112859b85d50de2a7e63f73c8fc70b99eea24291",
"build_date" : "2025-04-08T15:13:46.049795831Z",
"build_snapshot" : false,
"lucene_version" : "10.1.0",
"minimum_wire_compatibility_version" : "8.18.0",
"minimum_index_compatibility_version" : "8.0.0"
},
"tagline" : "You Know, for Search"
}
server.host: "0.0.0.0"
server.publicBaseUrl: "http://X.X.X.X:5601"
root@host:~# systemctl start kibana.service
root@host:~# /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
eyJ2ZXIiOiI4LjEuMiIsImFkciI6WyIxOTIuMTY4LjEuNjY6OTIwMCJdLCJmZ3IiOiJmYzdiZmFmMjNmODEzN2M1NmY4YTg1NGMxNTdjMWFkYTNiZDdiOGM4NTE4YTZhNmI3wWNiYzBkNzc0ZTRjNzc1Iiwia2V5Ijoib1ZBTkVJQUIxWVNBT0BiUWVsUVc6cEU1WXF3U1FTUENjcFFaZUJvTGtKdyJ0
root@host:~# /usr/share/kibana/bin/kibana-verification-code
Your verification code is: 139 477
Depuis la version 8, Elasticsearch est automatiquement configuré pour chiffrer ses communications.
Ce n'est pas le cas pour Kibana, avec lequel nous nous connectons en utilisant HTTP. Nous allons voir comment activer les connexions en HTTPS.
root@host:~# /usr/share/kibana/bin/kibana-encryption-keys generate
## Kibana Encryption Key Generation Utility
The 'generate' command guides you through the process of setting encryption keys for:
xpack.encryptedSavedObjects.encryptionKey
Used to encrypt stored objects such as dashboards and visualizations
https://www.elastic.co/guide/en/kibana/current/xpack-security-secure-saved-objects.html#xpack-security-secure-saved-objects
xpack.reporting.encryptionKey
Used to encrypt saved reports
https://www.elastic.co/guide/en/kibana/current/reporting-settings-kb.html#general-reporting-settings
xpack.security.encryptionKey
Used to encrypt session information
https://www.elastic.co/guide/en/kibana/current/security-settings-kb.html#security-session-and-cookie-settings
Already defined settings are ignored and can be regenerated using the --force flag. Check the documentation links for instructions on how to rotate encryption keys.
Definitions should be set in the kibana.yml used configure Kibana.
Settings:
xpack.encryptedSavedObjects.encryptionKey: caeb7879368e3dd66d7302f6810daec1
xpack.reporting.encryptionKey: c1c89f500966ac710f7fa5eaf2939976
xpack.security.encryptionKey: e1458d710ffb321e4a4f4eb792c78b2b
[…]
xpack.encryptedSavedObjects.encryptionKey: caeb7879368e3dd66d7302f6810daec1
xpack.reporting.encryptionKey: c1c89f500966ac710f7fa5eaf2939976
xpack.security.encryptionKey: e1458d710ffb321e4a4f4eb792c78b2b
root@host:~# /usr/share/elasticsearch/bin/elasticsearch-keystore show xpack.security.http.ssl.keystore.secure_password
592l_UJGSXmliJIvuokDab
root@host:~# cd /etc/kibana/
root@host:~# openssl pkcs12 -in /etc/elasticsearch/certs/http.p12 -out server.crt -clcerts -nokeys
Enter Import Password:592l_UJGSXmliJIvuokDab
root@host:~# openssl pkcs12 -in /etc/elasticsearch/certs/http.p12 -out server.key -nocerts -nodes
Enter Import Password:592l_UJGSXmliJIvuokDab
root@host:~# chown root:kibana /etc/kibana/server.*
root@host:~# chmod g+r /etc/kibana/server.*
server.ssl.enabled: true
server.ssl.certificate: /etc/kibana/server.crt
server.ssl.key: /etc/kibana/server.key
root@host:~# systemctl restart kibana.service
Attendre quelques secondes et connectez vous à kibana à l'adresse https://X.X.X.X:5601
Pour que nos services Elasticsearch et Kibana se lancent automatiquement au démarrage du serveur, nous devons effectuer quelques modifications.
root@host:~# systemctl enable elasticsearch.service
root@host:~# systemctl enable kibana.service
root@host:~# tail /var/log/elasticsearch/elasticsearch.log
root@host:~# journalctl --unit elasticsearch
root@host:~# tail /var/log/kibana/kibana.log
root@host:~# journalctl --unit kibana
Nous disposons désormais d'une solution Elastic pleinement opérationnelle. La prochaine étape consiste à déployer des modules afin de permettre à nos serveurs et à nos équipements réseau de transmettre leurs journaux pour une analyse centralisée.
Contact :