Setting Up Wazuh in Ubuntu
What is Wazuh
Wazuh is an open-source security platform that offers threat detection, visibility, and compliance management capabilities for modern IT environments. Originally derived from the OSSEC project, Wazuh has evolved into a robust and scalable solution designed to help organizations detect and respond to security incidents effectively.
At its core, Wazuh combines host-based intrusion detection system (HIDS), log monitoring, vulnerability detection, and security information and event management (SIEM) functionality into a unified platform. It provides real-time analysis of security alerts generated by various data sources, including system logs, network traffic, and endpoint telemetry.
Installation
Download the wazuh-certs-tool.sh script and the config.yml configuration file. This creates the certificates that encrypt communications between the Wazuh central components.
curl -sO https://packages.wazuh.com/4.7/wazuh-certs-tool.sh
curl -sO https://packages.wazuh.com/4.7/config.yml

Edit config.yml as shown below, add IP address

Run wazuh-certs-tool.sh to create the certificates. For a multi-node cluster, these certificates need to be later deployed to all Wazuh instances in your cluster.
bash ./wazuh-certs-tool.sh -A

Compress all the necessary files,
tar -cvf ./wazuh-certificates.tar -C ./wazuh-certificates/ .
rm -rf ./wazuh-certificates

Install the following packages if missing,
apt-get install debconf adduser procps

apt-get install gnupg apt-transport-https
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import && chmod 644 /usr/share/keyrings/wazuh.gpg
echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list
apt-get update

Install the Wazuh indexer package.
apt-get -y install wazuh-indexer

Edit the /etc/wazuh-indexer/opensearch.yml configuration file and replace the following values:
network.host: Sets the address of this node for both HTTP and transport traffic. The node will bind to this address and use it as its publish address. Accepts an IP address or a hostname.
Use the same node address set in config.yml to create the SSL certificates.
node.name: Name of the Wazuh indexer node as defined in the config.yml file. For example, node-1.
cluster.initial_master_nodes: List of the names of the master-eligible nodes. These names are defined in the config.yml file. Uncomment the node-2 and node-3 lines, change the names, or add more lines, according to your config.yml definitions.
discovery.seed_hosts: List of the addresses of the master-eligible nodes. Each element can be either an IP address or a hostname. You may leave this setting commented if you are configuring the Wazuh indexer as a single node. For multi-node configurations, uncomment this setting and set the IP addresses of each master-eligible node.
plugins.security.nodes_dn: List of the Distinguished Names of the certificates of all the Wazuh indexer cluster nodes. Uncomment the lines for node-2 and node-3 and change the common names (CN) and values according to your settings and your config.yml definitions.

Run the following commands replacing <indexer-node-name> with the name of the Wazuh indexer node you are configuring as defined in config.yml. For example, node-1. This deploys the SSL certificates to encrypt communications between the Wazuh central components.
NODE_NAME=<indexer-node-name>
mkdir /etc/wazuh-indexer/certs
tar -xf ./wazuh-certificates.tar -C /etc/wazuh-indexer/certs/ ./$NODE_NAME.pem ./$NODE_NAME-key.pem ./admin.pem ./admin-key.pem ./root-ca.pem
mv -n /etc/wazuh-indexer/certs/$NODE_NAME.pem /etc/wazuh-indexer/certs/indexer.pem
mv -n /etc/wazuh-indexer/certs/$NODE_NAME-key.pem /etc/wazuh-indexer/certs/indexer-key.pem
chmod 500 /etc/wazuh-indexer/certs
chmod 400 /etc/wazuh-indexer/certs/*
chown -R wazuh-indexer:wazuh-indexer /etc/wazuh-indexer/certs

Enable and start the Wazuh indexer service.
systemctl daemon-reload
systemctl enable wazuh-indexer
systemctl start wazuh-indexer

Repeat this stage of the installation process for every Wazuh indexer node in your cluster. Then proceed with initializing your single-node or multi-node cluster in the next stage.
Run the Wazuh indexer indexer-security-init.sh script on any Wazuh indexer node to load the new certificates information and start the single-node or multi-node cluster.
/usr/share/wazuh-indexer/bin/indexer-security-init.sh

Replace <WAZUH_INDEXER_IP> and run the following commands to confirm that the installation is successful.
curl -k -u admin:admin https://<WAZUH_INDEXER_IP>:9200

Replace <WAZUH_INDEXER_IP> and run the following command to check if the single-node or multi-node cluster is working correctly.
curl -k -u admin:admin https://<WAZUH_INDEXER_IP>:9200/_cat/nodes?v

Followed by wazuh-index, we will now install wazuh server.
apt-get -y install wazuh-manager

Enable and start the Wazuh manager service.
systemctl daemon-reload
systemctl enable wazuh-manager
systemctl start wazuh-manager

Install the Filebeat package.
apt-get -y install filebeat

Download the preconfigured Filebeat configuration file.
curl -so /etc/filebeat/filebeat.yml https://packages.wazuh.com/4.7/tpl/wazuh/filebeat/filebeat.yml
Edit the /etc/filebeat/filebeat.yml configuration file and replace the following value:
hosts: The list of Wazuh indexer nodes to connect to. You can use either IP addresses or hostnames. By default, the host is set to localhost hosts: [“127.0.0.1:9200”]. Replace it with your Wazuh indexer address accordingly.
If you have more than one Wazuh indexer node, you can separate the addresses using commas. For example, hosts: [“10.0.0.1:9200”, “10.0.0.2:9200”, “10.0.0.3:9200”]
Create a Filebeat keystore to securely store authentication credentials.
filebeat keystore create
Add the default username and password admin:admin to the secrets keystore.
echo admin | filebeat keystore add username --stdin --force
echo admin | filebeat keystore add password --stdin --force

Download the alerts template for the Wazuh indexer.
curl -so /etc/filebeat/wazuh-template.json https://raw.githubusercontent.com/wazuh/wazuh/v4.7.2/extensions/elasticsearch/7.x/wazuh-template.json
chmod go+r /etc/filebeat/wazuh-template.json

Install the Wazuh module for Filebeat.
curl -s https://packages.wazuh.com/4.x/filebeat/wazuh-filebeat-0.3.tar.gz | tar -xvz -C /usr/share/filebeat/module

Replace <server-node-name> with your Wazuh server node certificate name, the same one used in config.yml when creating the certificates. Then, move the certificates to their corresponding location.
NODE_NAME=<server-node-name>
mkdir /etc/filebeat/certs
tar -xf ./wazuh-certificates.tar -C /etc/filebeat/certs/ ./$NODE_NAME.pem ./$NODE_NAME-key.pem ./root-ca.pem
mv -n /etc/filebeat/certs/$NODE_NAME.pem /etc/filebeat/certs/filebeat.pem
mv -n /etc/filebeat/certs/$NODE_NAME-key.pem /etc/filebeat/certs/filebeat-key.pem
chmod 500 /etc/filebeat/certs
chmod 400 /etc/filebeat/certs/*
chown -R root:root /etc/filebeat/certs

Enable and start the Filebeat service.
systemctl daemon-reload
systemctl enable filebeat
systemctl start filebeat

Run the following command to verify that Filebeat is successfully installed.
filebeat test output

Your Wazuh server node is now successfully installed. Repeat this stage of the installation process for every Wazuh server node in your Wazuh cluster, then proceed with configuring the Wazuh cluster.
Once Wazuh Server is successfully installed, we will now install Wazuh Dashboard,
Install the following packages if missing.
apt-get install debhelper tar curl libcap2-bin

Install the Wazuh dashboard package.
apt-get -y install wazuh-dashboard

Edit the /etc/wazuh-dashboard/opensearch_dashboards.yml file and replace the following values:
server.host: This setting specifies the host of the Wazuh dashboard server. To allow remote users to connect, set the value to the IP address or DNS name of the Wazuh dashboard server. The value 0.0.0.0 will accept all the available IP addresses of the host.
opensearch.hosts: The URLs of the Wazuh indexer instances to use for all your queries. The Wazuh dashboard can be configured to connect to multiple Wazuh indexer nodes in the same cluster. The addresses of the nodes can be separated by commas. For example, [“https://10.0.0.2:9200", “https://10.0.0.3:9200","https://10.0.0.4:9200"]
Replace <dashboard-node-name> with your Wazuh dashboard node name, the same one used in config.yml to create the certificates, and move the certificates to their corresponding location.
NODE_NAME=<dashboard-node-name>
mkdir /etc/wazuh-dashboard/certs
tar -xf ./wazuh-certificates.tar -C /etc/wazuh-dashboard/certs/ ./$NODE_NAME.pem ./$NODE_NAME-key.pem ./root-ca.pem
mv -n /etc/wazuh-dashboard/certs/$NODE_NAME.pem /etc/wazuh-dashboard/certs/dashboard.pem
mv -n /etc/wazuh-dashboard/certs/$NODE_NAME-key.pem /etc/wazuh-dashboard/certs/dashboard-key.pem
chmod 500 /etc/wazuh-dashboard/certs
chmod 400 /etc/wazuh-dashboard/certs/*
chown -R wazuh-dashboard:wazuh-dashboard /etc/wazuh-dashboard/certs

Enable and start the Wazuh dashboard service.
systemctl daemon-reload
systemctl enable wazuh-dashboard
systemctl start wazuh-dashboard

Only for distributed deployments
Edit the /usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml file and replace the url value with the IP address or hostname of the Wazuh server master node.
Access the Wazuh web interface with your credentials.
URL: https://<wazuh-dashboard-ip>
Username and Password:: admin
If you face any error about wazuh-alerts, when access run below command
curl https://raw.githubusercontent.com/wazuh/wazuh/v4.4.4/extensions/elasticsearch/7.x/wazuh-template.json
curl -X PUT "https://localhost:9200/_template/wazuh" -H 'Content-Type: application/json' -d @ - -u <elasticsearch_user>:<elasticsearch_password> -k
systemctl restart filebeat.service
Subscribe to our YouTube channel: https://www.youtube.com/@CyberToolGuardian/featured
Follow us on Instagram:
https://instagram.com/cybertoolguardian
Check out the website:
https://cybertoolguardain.com
Comments
Post a Comment