WPK
Wazuh provides an automated way of building WPK packages using docker so there is no need for any other dependency.
You can see how to generate a WPK package, an X509 certificate and CA here.
To create a WPK package follow these steps:
Requirements
Docker
Git
Download our wazuh-packages repository from GitHub and go to the wpk directory of the 4.0 branch.
$ git clone https://github.com/wazuh/wazuh-packages && cd wazuh-packages/wpk && git checkout 4.0
Execute the generate_wpk_package.sh
script, with the different options you desire. This script will build a Docker image with all the necessary tools to create the WPK and run a container that will build it:
$ ./generate_wpk_package.sh -h
Usage: ./generate_wpk_package.sh [OPTIONS]
It is required to use -k or --aws-wpk-key, --aws-wpk-cert parameters
-t, --target-system <target> [Required] Select target wpk to build [linux/windows]
-b, --branch <branch> [Required] Select Git branch or tag
-d, --destination <path> [Required] Set the destination path of package.
-pn, --package-name <name> [Required for windows] Package name to pack on wpk.
-o, --output <name> [Required] Name to the output package.
-k, --key-dir <path> [Optional] Set the WPK key path to sign package.
--aws-wpk-key [Optional] AWS Secrets manager Name/ARN to get WPK private key.
--aws-wpk-cert [Optional] AWS secrets manager Name/ARN to get WPK certificate.
--aws-wpk-key-region [Optional] AWS Region where secrets are stored.
-a, --architecture <arch> [Optional] Target architecture of the package [x86_64].
-j, --jobs <number> [Optional] Number of parallel jobs when compiling.
-p, --path <path> [Optional] Installation path for the package. By default: /var/ossec.
-c, --checksum <path> [Optional] Generate checksum on the desired path.
-h, --help Show this help.
To use this tool, the previously required certificate and the key must be in the same directory.
Linux WPK
Below, you will find an example of Linux WPK package building.
# ./generate_wpk_package.sh -t linux -b v4.0.4 -d /tmp/wpk -k /tmp/keys -o LinuxAgent.wpk
This will build a 4.0.4 Wazuh Linux WPK package named LinuxAgent.wpk, using the with the previously generated keys that are saved in /tmp/keys
and store it in /tmp/wpk
.
Windows WPK
To build a WPK for Windows you need to first download an MSI package of the desired version:
# curl -O https://packages.wazuh.com/4.x/windows/wazuh-agent-4.0.4-1.msi
Below, you will find an example of Windows WPK package building.
# ./generate_wpk_package.sh -t windows -b v4.0.4 -d /tmp/wpk -k /tmp/keys -o WindowsAgent.wpk -pd /tmp/wazuh-agent-4.0.4-1.msi
This will build a 4.0.4 Wazuh Windows WPK package named WindowsAgent.wpk, using the with the previously generated keys that are saved in /tmp/keys
and store it in /tmp/wpk
.
If the -c
or --checksum
option is used there will be a file containing the SHA512 checksum in the same output path or you can indicate where you want to store it.
Here you can see an example of how to build a WPK generation with checksum:
# ./generate_wpk_package.sh -t linux -b v4.0.4 -d /tmp/wpk -k /tmp/keys -o LinuxAgent.wpk -c /tmp/wpk_checksum