Headed to Las Vegas for AWS re:Invent? Come visit us at booth #118!

How to connect a Wazuh agent to the STA

Wazuh, a fork of the famous OSSEC project, is an agent-based solution for the detection of malicious activity at the host level. It can detect rootkits, malicious processes running on the host, and many other types of malicious network activities. The Coralogix STA can function as a Wazuh manager, allowing Wazuh agents to connect to it, pull policies from it, and forward their logs to it. These logs will be enriched and forwarded to Coralogix for further processing.

Due to the communication mechanism used by Wazuh and its agents, Wazuh integration will only work properly for on-demand STA instances.

Once you have successfully installed the STA in an on-demand mode in your environment, you can configure Wazuh agents to connect to it by completing the following steps:

  1. Find out the relevant Wazuh NLB name (relevant only for cloud installations):
    1. If you have installed the STA by using CloudFormation, open your AWS CloudFormation console and locate the stack you have deployed. In the list of the resources that were deployed (in the “Resources” tab) locate the ID of the “WazuhNLB” that was deployed (should be something like ‘arn:aws:elasticloadbalancing:eu-west-1:746123456762:loadbalancer/net/STA-N-Wazuh-UJZ0XTYPZR41/1773e22e13f084de’)
    2. If you have installed the STA by using Terraform, run the following command in the folder you applied the Terraform template from: terraform state show 'module.sta_ng.module.sta_ng-spotfleet-small-wazuh1-eip1[0].aws_lb.WazuhNLB'. Take note of the id of the NLB. (should be something like ‘arn:aws:elasticloadbalancing:eu-west-1:746123456762:loadbalancer/net/STA-N-Wazuh-UJZ0XTYPZR41/1773e22e13f084de’)
  2. Find out the relevant Wazuh NLB DNS name:
    1. If you have installed the STA using either CloudFormation or Terraform, open your AWS EC2 console and navigate to the Load Balancers section and then search for the value you took note of at the previous step. Copy the DNS name of that load balancer (Should be something like STA-N-Wazuh-UXYZXYZXYR41-1234e12e12f064ed.elb.eu-west-1.amazonaws.com)
    2. If you are using the STA in an on-prem environment just use the STA’s host name
  3. Install the Wazuh agent as documented here: https://documentation.wazuh.com/current/installation-guide/wazuh-agent/index.html. Just set the WAZUH_MANAGER environment variable to the variable you took a note of at the previous step (the STA’s Wazuh NLB DNS name)
  4. Start the wazuh-agent service on the monitored instance
  5. Connect to the STA via SSH using the key pair you specified during the installation of the STA.
  6. Run the command sta-wazuh-list-agents. You should get something like this with the hostname of the monitored instance:
    Available agents:
    ID: 001, Name: ip-192-168-1-2, IP: any
  7. You should be able to see logs from the monitored instance that indicate interesting actions that took place on the monitored instance as recorded by Wazuh.
  8. You can automate that process in the cloud by adding these commands to the user data script of every instance that you launch. That way, during the instance’s first boot it will install and register its Wazuh agent. For example, this can be set as part of the userdata script of the instances you would like to monitor:
#!/bin/bash

curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | sudo apt-key add -
echo "deb https://packages.wazuh.com/4.x/apt/ stable main" | sudo tee -a /etc/apt/sources.list.d/wazuh.list
sudo apt-get update -y
export WAZUH_MANAGER="WazuhNLB-123456c78ubf90z26.elb.eu-west-1.amazonaws.com"
sudo -E apt-get install wazuh-agent -y
sudo service wazuh-agent enable
sudo service wazuh-agent start

Good luck (:

If you have any questions or need any additional help, please contact our support team via our 24/7 in-app chat!