wz.sh
· 1.2 KiB · Bash
Raw
#!/bin/bash
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
# Check if curl is installed
if ! command -v curl &> /dev/null; then
echo "curl is not installed. Installing curl..."
apt-get update
apt-get install -y curl
fi
# Add Wazuh repository
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import
chmod 644 /usr/share/keyrings/wazuh.gpg
# Add repository
echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list
# Update package index
apt-get update
# Install Wazuh agent
apt-get install -y wazuh-agent
# Configure Wazuh agent with multiple manager IPs
sed -i "s/MANAGER_IP/192.168.0.17,194.56.239.153/g" /var/ossec/etc/ossec.conf
# Enable and start Wazuh agent
systemctl daemon-reload
systemctl enable wazuh-agent
systemctl start wazuh-agent
# Check status
echo "Agent status:"
systemctl status wazuh-agent
# Show agent information
echo -e "\nAgent version information:"
/var/ossec/bin/wazuh-control info
echo -e "\nInstallation completed. Please check the status above to verify the connection."
1 | #!/bin/bash |
2 | |
3 | # Check if running as root |
4 | if [ "$EUID" -ne 0 ]; then |
5 | echo "Please run as root" |
6 | exit 1 |
7 | fi |
8 | |
9 | # Check if curl is installed |
10 | if ! command -v curl &> /dev/null; then |
11 | echo "curl is not installed. Installing curl..." |
12 | apt-get update |
13 | apt-get install -y curl |
14 | fi |
15 | |
16 | # Add Wazuh repository |
17 | curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import |
18 | chmod 644 /usr/share/keyrings/wazuh.gpg |
19 | |
20 | # Add repository |
21 | echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list |
22 | |
23 | # Update package index |
24 | apt-get update |
25 | |
26 | # Install Wazuh agent |
27 | apt-get install -y wazuh-agent |
28 | |
29 | # Configure Wazuh agent with multiple manager IPs |
30 | sed -i "s/MANAGER_IP/192.168.0.17,194.56.239.153/g" /var/ossec/etc/ossec.conf |
31 | |
32 | # Enable and start Wazuh agent |
33 | systemctl daemon-reload |
34 | systemctl enable wazuh-agent |
35 | systemctl start wazuh-agent |
36 | |
37 | # Check status |
38 | echo "Agent status:" |
39 | systemctl status wazuh-agent |
40 | |
41 | # Show agent information |
42 | echo -e "\nAgent version information:" |
43 | /var/ossec/bin/wazuh-control info |
44 | |
45 | echo -e "\nInstallation completed. Please check the status above to verify the connection." |