{"id":9590,"date":"2021-07-10T23:26:03","date_gmt":"2021-07-10T20:26:03","guid":{"rendered":"https:\/\/kifarunix.com\/?p=9590"},"modified":"2024-03-18T19:40:18","modified_gmt":"2024-03-18T16:40:18","slug":"install-wazuh-agent-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-wazuh-agent-on-rocky-linux-8\/","title":{"rendered":"Install Wazuh Agent on Rocky Linux 8"},"content":{"rendered":"\n
In this tutorial, you will learn how to install Wazuh agent on Rocky Linux 8. Our previous setup was on setting up Wazuh server with ELK on Rocky Linux. The Wazuh agent<\/a> is multi-platform and runs on the hosts that the user wants to monitor. It communicates with the Wazuh manager, sending data in near real time through an encrypted and authenticated channel<\/em>.<\/p>\n\n\n\n In our previous guide, we learnt how to install Wazuh server on Rocky Linux 8.<\/p>\n\n\n\n Install Wazuh Server on Rocky Linux 8<\/a><\/p>\n\n\n\n In this tutorial, we are going to install the Wazuh agent in another Rocky Linux 8 Desktop acting at the end point from which we are collecting logs. <\/p>\n\n\n\n Run the command below to create the Wazuh 4.x repository on Rocky Linux 8.<\/p>\n\n\n\n Import the Wazuh repository GPG key<\/p>\n\n\n\n Once the repos are in place, you can install Wazuh agent by running the command below;<\/p>\n\n\n\n The installation is now complete.<\/p>\n\n\n\n You can also specify the Wazuh manager from the command line. Replace the IP appropriately.<\/p>\n\n\n\n The next step is to enable the agent to communicate with the manager.<\/p>\n\n\n\n Login to Wazuh manager<\/strong>, and run the command below to add the agent to the server.<\/p>\n\n\n\n Select add an agent (A) and press enter.<\/p>\n\n\n\n Provide a name for the agent(in our case RockyLinux8Desktop) and IP of the agent and confirm.<\/p>\n\n\n\n Note the ID given to the agent<\/strong>, 001, in our case.<\/p>\n\n\n\n If you want to add more agents, please do so.<\/p>\n\n\n\n To automatically add the agent, Wazuh from the command line, simply use the command below;<\/p>\n\n\n\n For example, to add the second agent to Wazuh server;<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n You can list the agents using the command below;<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n For an agent to communicate with the manager, you need to register the the agent key from the server and install it on the agent.<\/p>\n\n\n\n There are two ways in which you can register Wazuh agents.<\/p>\n\n\n\n To manually register Wazuh agents, login to the server and extract the registration key for the specific Wazuh agent. You can use the Manual agent key extraction;<\/p>\n\n\n\n \/var\/ossec\/bin\/manage_agents<\/p>\n\n\n\n When command runs, select option E and specify the agent ID and press Enter.<\/p>\n\n\n\n Automatic agent Key extraction:<\/p>\n\n\n\n For example:<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n Copy the key and paste it in an accessible place as we will be using in the next step.<\/p>\n\n\n\n Set the Wazuh Server Address on Wazuh Agent<\/p>\n\n\n\n On the agent,<\/strong> edit the file \/var\/ossec\/etc\/ossec.conf<\/strong> and add the Wazuh manager IP\/resolvable hostname.<\/p>\n\n\n\n Save and quit<\/p>\n\n\n\n Import the Wazuh Agent Key extracted above<\/p>\n\n\n\n Press I to import the key previously generated from the manager.<\/p>\n\n\n\n Quit and restart the agent.<\/p>\n\n\n\n With the automatic agent registration, run the command below on Wazuh agent server.<\/p>\n\n\n\n Consult Sample output of the command;<\/p>\n\n\n\n Restart Wazuh agent;<\/p>\n\n\n\n Run the command below on Wazuh server to check agent status;<\/p>\n\n\n\n The agent registration is complete.<\/p>\n\n\n\n Check that the agents are now active. Note, we only connected a single agent in this setup.<\/p>\n\n\n\n To see more information, click on Active agents<\/strong> options.<\/p>\n\n\n\n Navigate to Wazuh>Modules>Security Events <\/strong>to view security related events and dashboards.<\/p>\n\n\n\n You can explore more on the modules such as Auditing and Policy Monitoring,Regulatory Compliance and Threat Detection and Response.<\/p>\n\n\n\n That concludes our guide on how to install Wazuh agent.<\/p>\n\n\n\n Wazuh Agent installation<\/p>\n\n\n\n Install OSSEC Agent on Rocky Linux 8<\/a><\/p>\n\n\n\n Install Nagios NRPE Agent on Rocky Linux 8<\/a><\/p>\n\n\n\nInstalling Wazuh Agent on Rocky Linux 8<\/h2>\n\n\n\n
Create the Wazuh Repository<\/h3>\n\n\n\n
\ncat > \/etc\/yum.repos.d\/wazuh.repo << 'EOL'\n[wazuh_repo] \ngpgcheck=1 \ngpgkey=https:\/\/packages.wazuh.com\/key\/GPG-KEY-WAZUH \nenabled=1 \nname=Wazuh repository \nbaseurl=https:\/\/packages.wazuh.com\/4.x\/yum\/ \nprotect=1 \nEOL\n<\/code><\/pre>\n\n\n\n
rpm --import http:\/\/packages.wazuh.com\/key\/GPG-KEY-WAZUH<\/code><\/pre>\n\n\n\n
Install Wazuh Agent<\/h3>\n\n\n\n
dnf -y install wazuh-agent<\/code><\/pre>\n\n\n\n
WAZUH_MANAGER=<\/strong>\"192.168.60.19\" dnf install wazuh-agent<\/code><\/pre>\n\n\n\n
Add Wazuh Agent on Wazuh Server<\/h3>\n\n\n\n
\/var\/ossec\/bin\/manage_agents<\/code><\/pre>\n\n\n\n
\nWazuh v4.1.5 Agent manager. *\nThe following options are available: *\n\n(A)dd an agent (A).\n(E)xtract key for an agent (E).\n(L)ist already added agents (L).\n(R)emove an agent (R).\n(Q)uit.\nChoose your action: A,E,L,R or Q: A\n<\/code><\/pre>\n\n\n\n
\n- Adding a new agent (use '\\q' to return to the main menu).\n Please provide the following:\n * A name for the new agent: RockyLinux8Desktop\n * The IP Address of the new agent: 192.168.60.18\nConfirm adding it?(y\/n): y\nAgent added with ID 001.\n<\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/manage_agents -a <agent_IP> -n <agent_name><\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/manage_agents -a 192.168.60.20 -n Ubuntu20<\/code><\/pre>\n\n\n\n
\n****************************************\n* Wazuh v4.1.5 Agent manager. *\n* The following options are available: *\n****************************************\n (A)dd an agent (A).\n (E)xtract key for an agent (E).\n (L)ist already added agents (L).\n (R)emove an agent (R).\n (Q)uit.\nChoose your action: A,E,L,R or Q: \n- Adding a new agent (use '\\q' to return to the main menu).\n Please provide the following:\n * A name for the new agent: * The IP Address of the new agent: Confirm adding it?(y\/n): Agent added with ID 002.\n\nmanage_agents: Exiting.\n<\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/manage_agents -l<\/code><\/pre>\n\n\n\n
Available agents:
ID: 001, Name: RockyLinux8Desktop, IP: 192.168.60.18
ID: 002, Name: Ubuntu20, IP: 192.168.60.20<\/code><\/pre>\n\n\n\nRegister Wazuh Agents<\/h3>\n\n\n\n
\n
Manual Wazuh Agent Registration<\/h4>\n\n\n\n
\/var\/ossec\/bin\/manage_agents<\/strong><\/code> command manually or automatically as shown below;<\/p>\n\n\n\n
\n****************************************\n* Wazuh v4.1.5 Agent manager. *\n* The following options are available: *\n****************************************\n (A)dd an agent (A).\n (E)xtract key for an agent (E).\n (L)ist already added agents (L).\n (R)emove an agent (R).\n (Q)uit.\nChoose your action: A,E,L,R or Q: E<\/strong>\n\nAvailable agents: \n ID: 001, Name: RockyLinux8Desktop, IP: 192.168.60.18\n ID: 002, Name: Ubuntu20, IP: 192.168.60.20\nProvide the ID of the agent to extract the key (or '\\q' to quit): 001<\/strong>\n\nAgent key information for '001' is: \nMDAxIFJvY2t5TGludXg4RGVza3RvcCAxOTIuMTY4LjYwLjE4IDhmYjY5OGNjMTRmMGI4Zjg1NjIxZDk2ODgxOTM1M2JkODA5ZTE3NTRiZjA5MGQ4NTdlY2E5ZjgxZmEzMDBjMzM=<\/strong>\n\n** Press ENTER to return to the main menu.\n...\n<\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/manage_agents -e <agent-id><\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/manage_agents -e 001<\/code><\/pre>\n\n\n\n
Agent key information for '001' is: \nMDAxIFJvY2t5TGludXg4RGVza3RvcCAxOTIuMTY4LjYwLjE4IDhmYjY5OGNjMTRmMGI4Zjg1NjIxZDk2ODgxOTM1M2JkODA5ZTE3NTRiZjA5MGQ4NTdlY2E5ZjgxZmEzMDBjMzM=<\/code><\/pre>\n\n\n\n
vim \/var\/ossec\/etc\/ossec.conf<\/code><\/pre>\n\n\n\n
... \n<ossec_config>\n <client>\n <server>\n <address>192.168.60.19<\/strong><\/address>\n <port>1514<\/port>\n <protocol>tcp<\/protocol>\n <\/server>\n...<\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/manage_agents<\/code><\/pre>\n\n\n\n
\n****************************************\n* Wazuh v4.1.5 Agent manager. *\n* The following options are available: *\n****************************************\n (I)mport key from the server (I).\n (Q)uit.\nChoose your action: I or Q: I\n\n* Provide the Key generated by the server.\n* The best approach is to cut and paste it.\n*** OBS: Do not include spaces or new lines.\n\nPaste it here (or '\\q' to quit): MDAxIFJvY2t5TGludXg4RGVza3RvcCAxOTIuMTY4LjYwLjE4IDhmYjY5OGNjMTRmMGI4Zjg1NjIxZDk2ODgxOTM1M2JkODA5ZTE3NTRiZjA5MGQ4NTdlY2E5ZjgxZmEzMDBjMzM=\n\nAgent information:\n ID:001\n Name:RockyLinux8Desktop\n IP Address:192.168.60.18\n\nConfirm adding it?(y\/n): y\nAdded.\n...\n<\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/ossec-control restart<\/code><\/pre>\n\n\n\n
Automatic Wazuh Agent Registration<\/h4>\n\n\n\n
\/var\/ossec\/bin\/agent-auth -m 192.168.60.19 -A RockyLinux8Desktop -I 192.168.60.18<\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/agent-auth -h<\/strong><\/code> for more info on command line options used.<\/p>\n\n\n\n
\n2021\/07\/10 15:51:15 agent-auth: INFO: Started (pid: 19633).\n2021\/07\/10 15:51:15 agent-auth: INFO: Requesting a key from server: 192.168.60.19\n2021\/07\/10 15:51:15 agent-auth: INFO: No authentication password provided\n2021\/07\/10 15:51:15 agent-auth: INFO: Using agent name as: RockyLinux8Desktop\n2021\/07\/10 15:51:15 agent-auth: INFO: Waiting for server reply\n2021\/07\/10 15:51:15 agent-auth: INFO: Valid key received\n<\/code><\/pre>\n\n\n\n
systemctl restart wazuh-agent<\/code><\/pre>\n\n\n\n
List Active Wazuh Agents on Wazuh Server<\/h4>\n\n\n\n
\/var\/ossec\/bin\/agent_control -l<\/code><\/pre>\n\n\n\n
Wazuh agent_control. List of available agents:\n ID: 000, Name: localhost.localdomain (server), IP: 127.0.0.1, Active\/Local\n ID: 001, Name: RockyLinux8Desktop, IP: 192.168.60.18, Active\n ID: 002, Name: Ubuntu20, IP: 192.168.60.20, Never connected\n\nList of agentless devices:<\/code><\/pre>\n\n\n\n
Verify Agent Data Reception on Kibana<\/h3>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
Reference<\/h3>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n