# Wazuh 4 training, part 3: upgrades and central configuration

> Wazuh 4 training part 3: remote agent upgrade, the agent-upgrade module, agent.conf with filters, verify-agent-conf, remote commands and mass deployment.

Published: 2026-11-28. Category: Deployment. Tags: Wazuh 4, Wazuh 4 training. URL: https://wazuh.blog/en/blog/wazuh-4-training-part-3/ Polish original: https://wazuh.blog/blog/szkolenie-wazuh-4-czesc-3/

The third part of the [Wazuh 4 training](/en/blog/wazuh-4-training-introduction/) builds on the three agents from [part 2](/en/blog/wazuh-4-training-part-2/). First I upgrade them from the manager, then I fill in the `agent.conf` files of the `example-linux` and `example-windows` groups and check that every agent received the right configuration. At the end I put it all into a sequence of steps for mass deployment. Options and defaults come from the Wazuh 4.14 documentation.

In the examples the agents have the IDs `001` (`agent-01`), `002` (`agent-02`) and `003` (`example-win-01`), and the manager is called `manager.example.com`.

## Exercise 1: which agents are outdated

Remote upgrade has three paths: the dashboard, the `/var/ossec/bin/agent_upgrade` tool on the manager, and the server API. The documentation recommends the API when a cluster is running. I start with the list of agents that run an older version than the manager. In the dashboard they are marked with a red dot after the version number in Agents management > Summary, and hovering shows the `Outdated` label.

On the manager the tool gives the same result:

```bash
# List agents that run an older version than the manager
/var/ossec/bin/agent_upgrade -l
```

The output has the columns `ID`, `Name` and `Version` and the footer `Total outdated agents: N`. The API returns the same list:

```bash
# List outdated agents through the server API
curl -k -X GET "https://localhost:55000/agents/outdated?pretty=true" -H "Authorization: Bearer $TOKEN"
```

The response has the fields `version`, `id` and `name` for every agent in `affected_items`. For a quick overview the `jq` filter from part 1 is enough:

```bash
# One line per outdated agent: ID, name, version
curl -sk -X GET "https://localhost:55000/agents/outdated" -H "Authorization: Bearer $TOKEN" | jq -r '.data.affected_items[] | [.id, .name, .version] | @tsv'
```

Each output row is one agent with an older version than the manager: ID, name and agent version. An empty result means every agent runs the manager version.

## Exercise 2: upgrade through the API

The API is convenient because it returns a task ID and lets me check the result with a separate request. I start the upgrade by naming the agents in `agents_list`:

```bash
# Create upgrade tasks for agents 001 and 003
curl -k -X PUT "https://localhost:55000/agents/upgrade?agents_list=001,003&pretty=true" -H "Authorization: Bearer $TOKEN"
```

The response has the message `All upgrade tasks were created` and a `task_id` field for every agent. The `agents_list` parameter also accepts the value `all`, which sends the request to all agents, and this applies to the `PUT /agents/upgrade_custom` endpoint as well. When upgrading more than 3000 agents at once, the documentation recommends setting `wait_for_complete=true` to avoid an API response timeout. That number comes from tests on a manager with an AMD EPYC 7000 2.5 GHz processor and 4 GiB of memory; with 3000 agents or fewer on a similar or stronger machine the response arrives before the limit.

The task result is checked with a separate endpoint:

```bash
# Check the result of the upgrade tasks
curl -k -X GET "https://localhost:55000/agents/upgrade_result?agents_list=001,003&pretty=true" -H "Authorization: Bearer $TOKEN"
```

Each item contains `agent`, `task_id`, `node` (the cluster node that executed the task), `module` equal to `upgrade_module`, `command`, `status`, `create_time` and `update_time`. One line per task:

```bash
# One line per task: agent, status, last update
curl -sk -X GET "https://localhost:55000/agents/upgrade_result?agents_list=001,003" -H "Authorization: Bearer $TOKEN" | jq -r '.data.affected_items[] | [.agent, .status, .update_time] | @tsv'
```

The task status takes one of seven values: `In queue`, `Updating`, `Updated`, `Error`, `Cancelled`, `Timeout` and `Legacy`. For `Error` the `error_msg` field holds the cause, for example `SHA1 verification error`. The `Legacy` status means an upgrade to an old version whose agent does not report the result, so the result has to be checked manually. The documentation does not describe the other statuses in more detail.

After the upgrade finishes, the agent restarts automatically. I check the version once the agent is back in the `Active` status:

```bash
# Confirm the new version of the upgraded agents
curl -k -X GET "https://localhost:55000/agents?agents_list=001,003&select=version&pretty=true" -H "Authorization: Bearer $TOKEN"
```

The same information is in `agent_control -i 001` in the `Client version` row.

## Exercise 3: upgrade from the dashboard and the command line

In the dashboard, upgrading is available from version 4.9.0. In Agents management > Summary I select the outdated agents, choose More > Upgrade agents and click Upgrade in the dialog showing the number of selected agents. A single agent can be upgraded from the `...` menu in the Actions column, but the option is available only for active, outdated agents. The result is visible in the Upgrade tasks panel above the list and in Task details with the list of tasks, statuses and errors; Refresh shows the new versions. The dashboard user needs the `agent:upgrade` permission.

From the command line I use `agent_upgrade`:

```bash
# Upgrade one agent
/var/ossec/bin/agent_upgrade -a 002
# Upgrade several agents, IDs separated by spaces
/var/ossec/bin/agent_upgrade -a 001 003
```

A correct result starts with `Upgrading...`, then `Upgraded agents:` and a line with the agent ID, the old version and the new version. The tool options from the documentation:

| Option | Meaning | Default |
|--------|---------|---------|
| `-l`, `--list_outdated` | list of outdated agents | - |
| `-a ID` | IDs of the agents to upgrade, separated by spaces | - |
| `-F`, `--force` | forces the upgrade, skipping version validation | - |
| `-s`, `--silent` | no output | - |
| `-v VERSION` | target version | latest Wazuh version |
| `-r REPOSITORY` | address of the WPK file repository | `packages.wazuh.com/4.x/wpk/` |
| `-f FILE` | custom WPK file | - |
| `-x EXECUTE` | executable file inside the WPK file | `upgrade.sh` |
| `-d`, `--debug` | debug mode | - |
| `--http` | HTTP instead of HTTPS | - |

Two examples from the documentation show options that help outside the standard path:

```bash
# Upgrade to a chosen version from a custom WPK repository
/var/ossec/bin/agent_upgrade -a 002 -v v4.14.11 -r http://mycompany.wpkrepo.com/
# Install a custom WPK file with its own installer script
/var/ossec/bin/agent_upgrade -a 002 -d -f /root/upgrade_openscap_debian.wpk -x install.sh
```

The upgrade timeout defaults to the maximum the agent allows in the `execd.max_restart_lock` option from `internal_options.conf`. The default is 600 seconds and the allowed range is 0 to 3600. Since version 4.1.0 the upgrade is performed by the agent-upgrade module, so the tool can run on any cluster node. Upgrading the central components, that is the indexer, the manager and the dashboard, is covered in the post on [upgrading to Wazuh 4.14](/en/blog/wazuh-upgrade-4-14/), and restarting single agents through the API is covered in the [post on agent restarts](/en/blog/agent-restart-api/).

## Exercise 4: the agent-upgrade module and package verification

The agent-upgrade module is responsible for the upgrade. On the manager side it validates, downloads and sends WPK files, and on the agent side it executes commands and notifies the manager of the result. The `<agent-upgrade>` section in `ossec.conf` has to be written only when I change the defaults. Manager side options:

| Option | Default | Range and meaning |
|--------|---------|-------------------|
| `chunk_size` | 32768 | chunk size in KB, from 64 to 60000 |
| `wpk_repository` | `packages.wazuh.com/4.x/wpk/` | address of the repository with WPK files |
| `max_threads` | 8 | parallel threads, from 0 to 256; 0 means the number of CPU cores |

On the manager side the module is always enabled. On the agent it can be disabled, and then remote upgrade of that agent is blocked:

| Option | Default | Meaning |
|--------|---------|---------|
| `enabled` | `yes` | `no` blocks the agent upgrade |
| `notification_wait_start` | `5m` | time before retrying the confirmation if the first one went unanswered |
| `notification_wait_factor` | `2.0` | factor by which the interval grows, a value greater than 1.0 |
| `notification_wait_max` | `1h` | maximum interval between notifications |
| `ca_verification` | subsection with an `enabled` option set to `yes` | verification of the WPK file signature with the root CA certificate |
| `ca_store` | `etc/wpk_root.pem` | path to the CA certificate, relative to the installation directory or absolute |

When `enabled` in the `ca_verification` subsection is `no`, the agent accepts any WPK package from the manager. I leave it at `yes`, and then the agent needs the certificate with which the WPK was signed. The agent section example from the documentation:

```xml
<!-- On the agent side -->
<agent-upgrade>
  <enabled>yes</enabled>
  <notification_wait_start>60s</notification_wait_start>
  <notification_wait_factor>4</notification_wait_factor>
  <notification_wait_max>2h</notification_wait_max>
  <ca_verification>
    <enabled>yes</enabled>
    <ca_store>etc/wpk_root.pem</ca_store>
  </ca_verification>
</agent-upgrade>
```

Upgrade requests reach the module through the `queue/tasks/upgrade` socket in the installation directory, and results are read through `queue/tasks/task`. The `upgrade` command accepts the parameters `wpk_repo`, `version` (the last available by default), `use_http` (`false` by default), `force_upgrade` (`false` by default) and `package_type`, for example `rpm` or `deb`; the last one helps on unrecognized platforms. The `upgrade_custom` command sends a local WPK file and requires `file_path`, while `installer` replaces the default script (`upgrade.sh` on Linux and macOS, `upgrade.bat` on Windows). In a cluster the custom WPK file must exist on every manager node at the same path.

## Exercise 5: agent.conf, groups and filters

Now the configuration. The manager sends agents the files from the group directory `/var/ossec/etc/shared/<GROUP_NAME>/`. The agent stores them in `/var/ossec/etc/shared/`, without the group directory. The rules from the documentation:

- files whose name starts with a dot are not sent by the manager, and nothing is logged about it,
- binary files are not sent either, and the log shows `wazuh-remoted: ERROR: Invalid shared file '<path>'. Ignoring it.`,
- `ar.conf` always reaches the agents, even when it is not in the group directory,
- an agent in several groups gets the files of all groups merged into one, and the last group has priority.

The `agent.conf` file is valid only on the server, lives in the directory of each group and must be readable by the `wazuh` user. Its root element is `<agent_config>`. A file path under `/var/ossec/etc/shared/` longer than 224 characters is ignored (before 4.14.10 the limit was 200), and the API rejects a group configuration file larger than 10 MiB with HTTP 413. The manager builds `merged.mg` in memory, so very large files need about twice their size in free memory.

An `<agent_config>` block without attributes applies to all agents of the group. Three attributes narrow it to selected agents:

| Attribute | Match |
|-----------|-------|
| `name` | sregex (OS_Match) pattern against the agent name |
| `os` | sregex pattern against the agent operating system information |
| `profile` | sregex pattern against the agent profile list |

Matching is case-insensitive and not anchored unless the pattern uses `^` or `$`. The agent name and system are shown by `agent_control -i <ID>` in the `Agent Name` and `Operating system` rows. Agent profiles come from `<config-profile>` in the `<client>` section of its `ossec.conf`. Several profiles are separated by a comma and a space, and the `profile` filter matches against the whole list. Linux agent packages add system profiles to `<config-profile>`, for example `amzn, amzn2023` on Amazon Linux 2023 or `rhel, rhel9, rhel9.7` on RHEL 9.7. I add my own profile by hand:

```xml
<client>
  <server>
    <address>manager.example.com</address>
    ...
  </server>
  <config-profile>example-web, ubuntu</config-profile>
</client>
```

The `agent.conf` of the `example-linux` group with one common block, one block for the `ubuntu` profile, one for `amzn` and one for the agent named `agent-02`:

```xml
<agent_config>
  <localfile>
    <log_format>syslog</log_format>
    <location>/var/log/example-app.log</location>
  </localfile>
</agent_config>

<agent_config profile="ubuntu">
  <localfile>
    <log_format>syslog</log_format>
    <location>/var/log/auth.log</location>
  </localfile>
</agent_config>

<agent_config profile="amzn">
  <localfile>
    <log_format>syslog</log_format>
    <location>/var/log/secure</location>
  </localfile>
</agent_config>

<agent_config name="^agent-02$">
  <localfile>
    <log_format>syslog</log_format>
    <location>/var/log/agent-02-test.log</location>
  </localfile>
</agent_config>
```

The anchors in `^agent-02$` are needed because without them the pattern would also match `agent-02-test` or `my-agent-020`. The documentation shows an example with an alternative, `name="^agent01|^agent02"`, as well as `os="^Linux"` and `profile="^UnixHost"`.

When combining with the regular `ossec.conf`, the order is: the agent reads `ossec.conf` first, then the shared `agent.conf`, and the last value of a setting wins. File paths set in both places both end up in the final configuration. The example from the documentation: an `ossec.conf` with `<enabled>no</enabled>` in the `<sca>` section and three policies, and an `agent.conf` with `<enabled>yes</enabled>` and a fourth policy. The result is an enabled SCA module with all four policies. Shared configuration does not cover the whole `<client>` section: from it only `force_reconnect_interval` is shared.

I fill in the files of the `example-windows` group in the same way, with `os="^Windows"` blocks or my own profile. A full description of groups and the order of their assignment is in the [post on agent groups](/en/blog/wazuh-agent-groups/).

## Exercise 6: deploying and verifying agent.conf

A change to `agent.conf` reaches the agents right away, so I do not leave an unfinished edit under the target name. The documentation describes four steps. First I create a temporary file whose name starts with a dot, which the manager does not distribute:

```bash
# Create a temporary file that the manager does not distribute
touch /var/ossec/etc/shared/example-linux/.agent.conf.tmp
chown wazuh:wazuh /var/ossec/etc/shared/example-linux/.agent.conf.tmp
chmod 660 /var/ossec/etc/shared/example-linux/.agent.conf.tmp
```

Then I put the blocks from exercise 5 into it and check the syntax with `verify-agent-conf`. Without the `-f` option the tool walks through the group directories in `/var/ossec/etc/shared` and checks every existing `agent.conf`:

```bash
# Validate the temporary file before it becomes active
/var/ossec/bin/verify-agent-conf -f /var/ossec/etc/shared/example-linux/.agent.conf.tmp
```

A good result is the line `verify-agent-conf: OK`, preceded by `verify-agent-conf: Verifying [...]` with the file path. Only after fixing the errors does the file get its target name:

```bash
# Activate the validated configuration
mv /var/ossec/etc/shared/example-linux/.agent.conf.tmp /var/ossec/etc/shared/example-linux/agent.conf
```

The manager detects the new file on its own and sends it to all agents of the group. Restarting the manager speeds up distribution. The agent sends the checksum of its `merged.mg` file on every keepalive, that is every `notify_time` (20 seconds by default). If the checksum differs from the manager one, the manager sends the new file, and the agent applies it immediately after receiving it. The documentation stresses that a manual restart is not needed then, regardless of the `auto_restart` setting. The `auto_restart` option in the `<client>` section defaults to `yes` and, according to its description, turns on the automatic restart of the agent after it receives a new, valid configuration.

How the reload happens depends on the system. On Linux `wazuh-agentd` keeps its connection to the manager while the other agent daemons restart. On Windows the whole service restarts, so the agent shows as disconnected for a few seconds. After the configuration is applied correctly, the agent log has these entries:

```text
wazuh-agentd: INFO: Agent is reloading due to shared configuration changes.
wazuh-agentd: INFO: SIGNAL [(10)-(User defined signal 1)] Received. Reload agentd.
wazuh-agentd: INFO: Buffer agent.conf updated, enable: 1 size: 30000
wazuh-agentd: INFO: Client buffer resized from 20000 to 30000 elements.
```

The last two lines refer to the example `client_buffer` change. On Windows, instead of the `agentd` reload the log shows `Received exit signal. Starting exit process.` and the service starting again. I check the group synchronization status in two ways:

```bash
# API: synchronization status of the group configuration of agent 001
curl -k -X GET "https://localhost:55000/agents?agents_list=001&select=group_config_status&pretty=true" -H "Authorization: Bearer $TOKEN"
# Tool: the same check on the manager
/var/ossec/bin/agent_groups -S -i 001
```

The API response contains `"group_config_status": "synced"`, and the tool returns `Agent '001' is synchronized.`. I check that the filters worked in the agent log: `agent-01` and `agent-02` read the file from the common block, on Ubuntu `/var/log/auth.log` is added, and only `agent-02` tries to read `/var/log/agent-02-test.log`. If that file does not exist, the agent log contains an error that does not stop the agent.

```bash
# Show which files the logcollector started to analyze
grep "Analyzing file" /var/ossec/logs/ossec.log
```

Group file names are subject to the limits from exercise 5. From version 4.14.10 Windows agents skip files whose names contain the characters `:`, `<`, `>`, `"`, `|`, `?` or `*`, end with a dot or a space, are device names such as `CON` or `NUL`, or look like 8.3 short names. Such entries land in the log as an invalid entry name.

An agent that is not supposed to apply the shared configuration gets a line in `/var/ossec/etc/local_internal_options.conf`:

```text
agent.remote_conf=0
```

The default value is `1`. This option lives on the agent, so restoring shared configuration requires a local change.

## Exercise 7: remote commands

Shared configuration can define command-based log sources, but the agent does not accept them by default. Three options in `/var/ossec/etc/local_internal_options.conf` on the agent, each with the default `0`, unlock individual features:

| Option | What it unlocks |
|--------|-----------------|
| `logcollector.remote_commands` | the `command` and `full_command` log sources, `socket` blocks and socket targets from shared configuration |
| `wazuh_command.remote_commands` | commands of the `command` module from shared configuration |
| `sca.remote_commands` | execution of commands from policy files received from the manager |

On Linux it is enough to append a line:

```bash
# Allow the logcollector to accept commands from the shared configuration
echo "logcollector.remote_commands=1" >> /var/ossec/etc/local_internal_options.conf
systemctl restart wazuh-agent
```

I enable the options only where commands from `agent.conf` are needed, because someone with access to the group files on the manager can then run commands on the agents. That warning is my own assessment; the documentation describes the options but does not assess the risk. The full list of things that can be configured remotely also includes `syscheck`, `rootcheck`, `localfile`, `labels`, `sca`, `syscollector`, `client_buffer`, the AWS, Azure and Google Cloud modules, GitHub, Office 365, Docker listener and `socket`.

## Exercise 8: mass deployment

For a larger number of agents I arrange the earlier exercises in a fixed order:

1. I prepare the groups and the `agent.conf` files with the `name`, `os` and `profile` filters, so that one file serves different systems in a group.
2. I prepare a reference `ossec.conf` and, if needed, `local_internal_options.conf` as a template for all agents.
3. I install the package with the deployment variables from part 2, which enroll the agent right away, give it a name and assign it to a group, without a separate `agent-auth` call.
4. I push the `ossec.conf` template, with `<config-profile>` inserted dynamically where I use profiles, and restart the agent service.

This is the sequence I recommend, assembled from elements described in the documentation: the deployment variables from part 2, `config-profile` and the `agent.conf` filters.

The documentation also describes downloading group configuration files from outside. At startup the manager reads the `files.yml` file from `/var/ossec/etc/shared/`:

```yaml
groups:
  my_group_1:
    files:
      agent.conf: https://example.com/agent.conf
      rootcheck.txt: https://example.com/rootcheck.txt
    poll: 15
  my_group_2:
    files:
      agent.conf: https://example.com/agent.conf
    poll: 200
```

The `groups` block names the groups whose files are downloaded. A missing group is created. The `poll` label is the download frequency in seconds. If a `merged.mg` file is on the list, only that file is downloaded and it is validated. The `files.yml` file can be changed at runtime: the manager reads it again without a restart, and the result is in `/var/ossec/logs/ossec.log`. A correct load gives `INFO: Successfully parsed of yaml file: /etc/shared/files.yml`, a file change gives `INFO: File '/etc/shared/files.yml' changed. Reloading data`, and errors give `ERROR: Failed to download file from url: https://example.com/merged.mg` or `ERROR: The downloaded file '/var/download/merged.mg' is corrupted.`.

## Checklist after part 3

- [ ] `agent_upgrade -l` or `GET /agents/outdated` shows the list of outdated agents.
- [ ] The upgrade tasks have the status `Updated` in `GET /agents/upgrade_result`.
- [ ] `Client version` in `agent_control -i` matches the manager version.
- [ ] The `agent.conf` files of the `example-linux` and `example-windows` groups pass `verify-agent-conf` with the result `OK`.
- [ ] `agent_groups -S -i <ID>` returns `synchronized` for every agent.
- [ ] The agent log confirms that the `profile` and `name` filters reached the right agents.
- [ ] `logcollector.remote_commands=1` is set only on agents that need it.

In part 4 I move from agents to logs: I check how Wazuh analyzes events, how long it keeps them and how to assess the first alerts.

## What the documentation does not specify

- The `agent_upgrade` page does not describe what exactly the "version validations" skipped by `-F` check, or whether a downgrade or an upgrade to the same version is allowed.
- The version threshold from which a task status is `Legacy` is not given.
- The central configuration page says the new configuration is applied without a manual restart regardless of `auto_restart`, while the `auto_restart` description in the `<client>` section speaks of a restart after receiving a new configuration. The relation between these descriptions is not explained.
- The documentation does not describe what the manager does when an activated `agent.conf` is invalid and `verify-agent-conf` was skipped.
- The central configuration page gives the `local_internal_options.conf` file only for Linux (`/var/ossec/etc/`). It does not describe the location of that file on a Windows agent.
- The time for a new group file to reach the agents is described only by the keepalive cycle and the advice to restart the manager.

## Sources

- https://documentation.wazuh.com/4.14/user-manual/agent/agent-management/remote-upgrading/upgrading-agent.html
- https://documentation.wazuh.com/4.14/user-manual/agent/agent-management/remote-upgrading/agent-upgrade-module.html
- https://documentation.wazuh.com/4.14/user-manual/reference/tools/agent-upgrade.html
- https://documentation.wazuh.com/4.14/user-manual/reference/ossec-conf/agent-upgrade.html
- https://documentation.wazuh.com/4.14/user-manual/reference/centralized-configuration.html
- https://documentation.wazuh.com/4.14/user-manual/reference/tools/verify-agent-conf.html
- https://documentation.wazuh.com/4.14/user-manual/reference/internal-options.html
- https://documentation.wazuh.com/4.14/user-manual/reference/ossec-conf/client.html
