Diagram of a Wazuh agent talking to the manager on ports 1515 and 1514, with watching, rules and upgrade order
|

How-to: install a Wazuh agent and get something out of it

Install a Wazuh agent on Rocky Linux, check the connection, then enable file integrity, SCA, vulnerability detection and your own custom rules.

Wazuh is an open-source security monitoring platform: a central manager collects and analyses, agents installed on each machine send logs and observations. A single Wazuh agent does the work of several tools once installed separately: log collection, file integrity monitoring (the job of AIDE or Tripwire), configuration audit (Lynis’s), package vulnerability detection (Trivy’s for the system), rootkit hunting.

This tutorial assumes a Wazuh 4.x manager is already running. It installs an agent on a Rocky Linux server, enrols it properly, makes it watch what really matters, and shows how to write your first rules: one to silence known noise, one to raise an alert that matters. The goal isn’t thousands of alerts, but few, and meaningful.

Diagram of a Wazuh agent talking to the manager on ports 1515 and 1514, with watching, rules and upgrade order
What the agent sends, what the manager does with it, and how to tune it.

What a Wazuh agent does

ModuleWhat it doesTuning needed
log collectionsends logs to the manager, which decodes them and applies its rulesadd your application logs
file integrity (syscheck)detects file creations, changes, deletionspick directories, enable real time
SCAchecks configuration against the distribution’s CIS benchmarknone
inventory (syscollector)lists packages, ports, processes, interfacesnone
vulnerabilitiesthe manager matches the inventory against CVE databasesnone on the agent side
rootchecklooks for known rootkit signs and anomaliesnone

Step 1: on the manager, getting ready

The agent talks to the manager on two TCP ports: 1514 for events (encrypted with a key unique to each agent) and 1515 for enrolment, where the agent obtains that key. Open them only to your machines’ addresses:

firewall-cmd --permanent --new-zone=wazuh-agents
firewall-cmd --permanent --zone=wazuh-agents --add-source=203.0.113.25/32
firewall-cmd --permanent --zone=wazuh-agents --add-source=203.0.113.40/32
firewall-cmd --permanent --zone=wazuh-agents --add-port=1514/tcp --add-port=1515/tcp
firewall-cmd --reload

Without an enrolment password, anyone who can reach port 1515 can register a fake agent and send fake events. Turn it on:

<!-- /var/ossec/etc/ossec.conf on the manager -->
<auth>
  <disabled>no</disabled>
  <port>1515</port>
  <use_password>yes</use_password>
  <ssl_verify_host>no</ssl_verify_host>
  <purge>yes</purge>
</auth>
openssl rand -base64 24 > /var/ossec/etc/authd.pass
chmod 640 /var/ossec/etc/authd.pass && chown root:wazuh /var/ossec/etc/authd.pass
systemctl restart wazuh-manager

purge lets a reinstalled machine re-enrol under the same name: the old entry is replaced instead of being refused as a duplicate.

Step 2: install the Wazuh agent, in the right version

Absolute rule: the agent’s version must never exceed the manager’s. A newer agent is refused at connection, with an unhelpful message. Always upgrade the manager first, then the agents, and install a specific version rather than “the latest”:

# /etc/yum.repos.d/wazuh.repo
[wazuh]
name=Wazuh
baseurl=https://packages.wazuh.com/4.x/yum/
gpgcheck=1
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
WAZUH_MANAGER='wazuh.example.org' \
WAZUH_REGISTRATION_PASSWORD='<enrolment password>' \
WAZUH_AGENT_NAME='web1.example.org' \
  dnf install wazuh-agent-4.14.9
systemctl daemon-reload
systemctl enable --now wazuh-agent

The package reads these environment variables during install, writes the manager’s address into ossec.conf, puts the password in authd.pass and enrols at first start. To keep a general dnf update from moving the agent ahead of the manager, exclude it from automatic updates (exclude=wazuh-agent in the repository file, or the versionlock plugin) and upgrade it deliberately, after the manager.

Step 3: check the Wazuh agent connection

grep ^status /var/ossec/var/run/wazuh-agentd.state      # status='connected'
tail -n 20 /var/ossec/logs/ossec.log
# on the manager:
/var/ossec/bin/agent_control -l                        # the agent is "Active"
/var/ossec/bin/agent_control -i 007                    # details: version, last keepalive

If the agent stays “disconnected”: firewall (on either side), wrong enrolment password, name already taken, or a version newer than the manager. ossec.log on the agent almost always says which.

A connected agent, for real

The agent on my web server, 2 November 2026, four hours after a reboot:

# /var/ossec/bin/wazuh-control info
WAZUH_VERSION="v4.14.9"
WAZUH_TYPE="agent"

# /var/ossec/bin/wazuh-control status
wazuh-modulesd is running...
wazuh-logcollector is running...
wazuh-syscheckd is running...
wazuh-agentd is running...
wazuh-execd is running...

# grep "Connected to the server" /var/ossec/logs/ossec.log | tail -1
2026/11/02 09:06:20 wazuh-agentd: INFO: (4102): Connected to the server ([wazuh.example.org]:1514/tcp).

# grep -E "^(status|last_keepalive|last_ack|msg_count|msg_sent|msg_buffer)" /var/ossec/var/run/wazuh-agentd.state
status='connected'
last_keepalive='2026-11-02 13:01:20'
last_ack='2026-11-02 13:01:20'
msg_count='117686'
msg_sent='118393'
msg_buffer='0'
  • Five daemons running: modulesd (inventory, SCA, vulnerability data), logcollector (reads logs), syscheckd (file integrity), agentd (the connection), execd (active responses). If one is missing, the matching feature is silently off.
  • Connected less than a minute after boot (the machine came up at 09:05:29): the agent starts early and reconnects on its own after a reboot of either side.
  • last_keepalive and last_ack at the same second: the agent sends, and the manager answers. A keepalive without an ack means the agent talks into the void: firewall on the way back, or a key the manager no longer recognises.
  • msg_buffer = 0: nothing waiting to be sent. This buffer fills when the manager is unreachable; if it stays high, events are being delayed, and once full they are dropped.
  • 117 686 messages in four hours, about 8 per second for a busy web server: mostly log lines, plus inventory and integrity results. That’s the order of magnitude to plan for when sizing the manager.

Step 4: make it read the right logs

By default the agent reads the classic system logs. Add your services’ logs:

<!-- /var/ossec/etc/ossec.conf on the agent -->
<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/nginx/error.log</location>
</localfile>
<localfile>
  <log_format>json</log_format>
  <location>/var/log/suricata/eve.json</location>
</localfile>
<localfile>
  <log_format>journald</log_format>
  <location>journald</location>
  <filter field="_SYSTEMD_UNIT">^sshd\.service$</filter>
</localfile>
  • syslog: the classic text format, one line per event, which the manager decodes with its shipped decoders;
  • json: for structured logs (Suricata, many modern applications). Each field becomes searchable in the dashboard and usable in rules;
  • journald: reads the systemd journal directly, filtered by unit. Essential for services that write to no file.

Don’t make the same agent read the same information through two paths (a file and the systemd journal, for example): each event would be counted twice.

Step 5: file integrity

<syscheck>
  <frequency>43200</frequency>
  <directories realtime="yes" check_all="yes" report_changes="yes">/etc/ssh,/etc/sudoers.d,/etc/nginx</directories>
  <directories realtime="yes" check_all="yes">/etc/passwd,/etc/shadow,/etc/group</directories>
  <directories check_all="yes">/usr/bin,/usr/sbin,/usr/local/bin</directories>
  <ignore type="sregex">\.swp$|~$</ignore>
  <nodiff>/etc/shadow</nodiff>
</syscheck>
  • frequency: a full scan every twelve hours for directories without real-time monitoring;
  • realtime: immediate monitoring through inotify, for files whose change must alert right away (SSH configuration, sudo, accounts);
  • report_changes: attaches the changed file’s diff to the alert. Precious for configuration; never on secret files, hence nodiff for /etc/shadow;
  • binaries (/usr/bin…): a change outside a package update is a strong sign of compromise. They’re numerous: no real time, the periodic scan is enough;
  • ignore: editor temporary files, which would raise alerts at every edit.

Every package update produces a burst of integrity alerts on binaries: that’s normal, and the manager ties them to dnf’s logs. What should worry you is a binary change without a matching update.

Step 6: SCA and vulnerabilities, for free

Configuration assessment (SCA) applies the distribution’s CIS benchmark every twelve hours and gives a score, with each failed check’s rationale and suggested remediation. Don’t aim for 100%: some checks assume a partitioning scheme or organisation that doesn’t apply to you. Read the list, fix what makes sense, and note why you ignore the rest.

Vulnerability detection relies on the package inventory the agent sends; the manager matches it against published vulnerability databases. It covers installed RPM packages. It doesn’t see what an application bundles itself: an embedded Node.js, a Python environment, a Go binary built with a vulnerable library. For those, you have to follow each project’s announcements.

Step 7: writing your own rules

The shipped rules cover the essentials, but they need adjusting. Yours go on the manager, in /var/ossec/etc/rules/, in a file of your own that no update will overwrite, with ids from 100000 up:

<!-- /var/ossec/etc/rules/local_tuning.xml (on the manager) -->
<group name="local,tuning,">
  <rule id="100900" level="0">
    <if_sid>550</if_sid>
    <field name="file">^/var/lib/myapp/cache/</field>
    <description>Known noise: application cache changing all the time</description>
  </rule>

  <rule id="100901" level="12">
    <if_sid>550</if_sid>
    <field name="file">^/etc/sudoers</field>
    <description>sudo configuration changed: $(file)</description>
    <group>privilege_escalation,</group>
  </rule>
</group>

Silencing known noise

A rule that shouts all the time makes you ignore all the others. Don’t disable the original rule: add a level-0 child rule (if_sid) targeting only the known case. Here rule 550 (“checksum changed”) stays active everywhere except for the application’s cache.

Raising what matters

Conversely, a change to the sudo configuration deserves more than the default level: rule 100901 lifts it to level 12, enough to trigger an immediate notification. The privilege_escalation group makes it easy to find in the dashboard.

The field name trap

The dashboard and the JSON alerts show the file path as syscheck.path. But in a rule, and in the description’s $(…) substitution, you must write file. With syscheck.path there’s no error at load time: the rule simply never fires, and the description shows up blank. I shipped two rule files broken this way before understanding it.

Test before reloading

/var/ossec/bin/wazuh-analysisd -t          # rule syntax
/var/ossec/bin/wazuh-logtest               # paste a line: which rules apply?
systemctl restart wazuh-manager

wazuh-logtest only simulates logs, not integrity events. For a syscheck rule, the test is real: change a file in the target directory on the agent, and look for the alert in /var/ossec/logs/alerts/alerts.json on the manager.

Upgrading the fleet

  • the manager first, indexer and dashboard included, following the release notes;
  • check that every agent is still “Active”;
  • then the agents, machine by machine, pinning the same version as the manager;
  • after each agent, agent_control -i must show the new version.

Going further

“Active responses” let the manager trigger an action on the agent in response to a rule (banning an address, for example). If CrowdSec or fail2ban already do that, refrain: two systems each banning on their own make unblocking painful. Wazuh is more useful as memory and as a correlation point than as an enforcer.


This post is part of a series of sysadmin tutorials (tag “how-to”).
Series “How-to”, tutorial 15/77. · ← Previous tutorial · Next tutorial → (coming 30 Nov) · Version française

Related articles

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *