Wazuh With ELK Guide
Wazuh With ELK Guide
04 servers 2
IP plan 2
1. IP plan
a. Wazuh server: 172.16.7.25
b. ELK server: 172.16.7.26
c. Agent installed on ubuntu Client : 172.16.7.24
i. # apt-get update
e. Install the Wazuh manager:
i. # apt-get install wazuh-manager
f. Check for service status
i. # systemctl status wazuh-manager
g. Add official NodeJS repository:
i. # curl -sL https://deb.nodesource.com/setup_10.x |
bash -
h. Install NodeJS
i. # apt-get install nodejs
i. Install the Wazuh API
i. # apt-get install wazuh-api
j. Check for service status
i. # systemctl status wazuh-api
k. Secure the wazuh API (enable https with self signed cert and set username and
password for API connection)
i. # /var/ossec/api/scripts/configure_api.sh
l. Restart service
i. # systemctl restart wazuh-api
m. Test wazuh server is running properly:
i. https://172.16.7.25:55000
Filebeat Installation
o. Install Filebeat:
p. Download the Filebeat config file from the Wazuh repository. This is
pre-configured to forward Wazuh alerts to Elasticsearch:
i. # curl -s
https://packages.wazuh.com/3.x/filebeat/wazuh-fil
ebeat-0.1.tar.gz | sudo tar -xvz -C
/usr/share/filebeat/module
s. Edit the file /etc/filebeat/filebeat.yml and replace with the IP address or the
hostname of the Elasticsearch server. For example:
i. # vi /etc/filebeat/filebeat.yml
output.elasticsearch.hosts:
['http://172.16.7.26:9200']
i. # systemctl daemon-reload
ii. # systemctl enable filebeat.service
iii. # systemctl start filebeat.service
Install Elasticsearch
i. # rpm --import
https://artifacts.elastic.co/GPG-KEY-elasticsearc
h
i. # vi /etc/elasticsearch/elasticsearch.yml
network.host: 172.16.7.26
http.port: 9200
d. Add or edit (if commented) the following lines in the file
/etc/elasticsearch/elasticsearch.yml:
i. # vi /etc/elasticsearch/elasticsearch.yml
node.name: wazuh
cluster.initial_master_nodes: ["wazuh"]
i. # systemctl daemon-reload
ii. # systemctl enable elasticsearch.service
iii. # systemctl start elasticsearch.service
f. Ensure elasticsearch is running
i. http://172.16.7.26:9200
g. Now, in wazuh server(172.16.7.25) load the filebeat template, as mentioned
earlier in filebeat installation.
Install Kibana:
i. # chown -R kibana:kibana
/usr/share/kibana/optimize
ii. # chown -R kibana:kibana
/usr/share/kibana/plugins
i. # cd /usr/share/kibana/
ii. # sudo -u kibana bin/kibana-plugin install
https://packages.wazuh.com/wazuhapp/wazuhapp-3.13
.2_7.9.1.zip
i. # vi /etc/kibana/kibana.yml
server.port: 5601
server.host: "172.16.7.26"
server.name: "wazuh kibana"
elasticsearch.hosts:
["http://172.16.7.26:9200"]
i. # systemctl daemon-reload
ii. # systemctl enable kibana.service
iii. # systemctl start kibana.service
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mo
de: certificate
xpack.security.transport.ssl.key:
/etc/elasticsearch/certs/elasticsearch.key
xpack.security.transport.ssl.certificate:
/etc/elasticsearch/certs/elasticsearch.crt
xpack.security.transport.ssl.certificate_aut
horities: [
"/etc/elasticsearch/certs/ca/ca.crt" ]
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.verification_mode:
certificate
xpack.security.http.ssl.key:
/etc/elasticsearch/certs/elasticsearch.key
xpack.security.http.ssl.certificate:
/etc/elasticsearch/certs/elasticsearch.crt
xpack.security.http.ssl.certificate_authorit
ies: [ "/etc/elasticsearch/certs/ca/ca.crt"
]
server.ssl.enabled: true
server.ssl.certificate:
"/etc/kibana/certs/kibana.crt"
server.ssl.key:
"/etc/kibana/certs/kibana.key"
ix. Restart the service
# systemctl restart kibana
f. Configure Filebeat installed on wazuh server
Copy certificates and keys from elk server to wazuh server
# cd /usr/share/elasticsearch
# scp -r ca wazuh [email protected]:/home/wazuh
g. Configure the filebeat
i. # mkdir /etc/filebeat/certs/ca -p
ii. # cd /home/wazuh
iii. # cp ca/ca.crt /etc/filebeat/certs/ca
iv. # cp wazuh-manager/wazuh.crt /etc/filebeat/certs
v. # cp wazuh-manager/wazuh.key /etc/filebeat/certs
vi. # chmod 770 -R /etc/filebeat/certs
vii. Make the following changes to /etc/filebeat/filebeat.yml:
output.elasticsearch.hosts:
['172.16.7.26:9200']
output.elasticsearch.protocol: https
output.elasticsearch.ssl.certificate:
"/etc/filebeat/certs/wazuh.crt"
output.elasticsearch.ssl.key:
"/etc/filebeat/certs/wazuh.key"
output.elasticsearch.ssl.certificate_authori
ties: ["/etc/filebeat/certs/ca/ca.crt"]
h. Restart the service:
# systemctl restart filebeat
j. Restart Elasticsearch
i. # systemctl restart elasticsearch
k. Auto generate credentials for all prebuilt users and roles
#
/usr/share/elasticsearch/bin/elasticsearch-setup-passw
ords auto
iii. # vi /etc/kibana/kibana.yml
xpack.security.enabled: true
elasticsearch.username: "elastic"
elasticsearch.password:
"He7FY50syQ4dI9oWRIqA”