108 lines
3.0 KiB
Bash
Executable File
108 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Obtener la clave de agente del servidor wazuh
|
|
echo "Ingrese la key del agente:"
|
|
read agent_key
|
|
server_ip="140.82.30.232"
|
|
# Obtener nombre de la distro
|
|
|
|
echo "Detectando distro"
|
|
|
|
distro=$(lsb_release -si)
|
|
|
|
case "$distro" in
|
|
Ubuntu)
|
|
echo "Distribucion detectada: Ubuntu"
|
|
echo "Familia principal: Debian"
|
|
echo "Paqueteria: DEB"
|
|
|
|
# Descargar e instalar el agente de Wazuh
|
|
wget -qO - https://packages.wazuh.com/key/GPG-KEY-WAZUH | apt-key add -
|
|
echo "deb https://packages.wazuh.com/4.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list
|
|
apt-get update
|
|
WAZUH_MANAGER="$server_ip" apt-get install wazuh-agent
|
|
/var/ossec/bin/manage_agents -i $agent_key
|
|
|
|
# Iniciar el agente de Wazuh
|
|
systemctl daemon-reload
|
|
systemctl enable wazuh-agent
|
|
systemctl start wazuh-agent
|
|
|
|
# Desactivar las actualizaciones automáticas del agente
|
|
echo "Desactivando actualizaciones del wazuh-agent"
|
|
sed -i "s/^deb/#deb/" /etc/apt/sources.list.d/wazuh.list
|
|
apt-get update
|
|
;;
|
|
|
|
CentOS)
|
|
echo "Distribucion detectada: CentOS"
|
|
echo "Familia principal: RedHat"
|
|
echo "Paqueteria: RPM"
|
|
|
|
rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
|
|
|
|
cat > /etc/yum.repos.d/wazuh.repo << EOF
|
|
[wazuh]
|
|
gpgcheck=1
|
|
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
|
|
enabled=1
|
|
name=EL-\$releasever - Wazuh
|
|
baseurl=https://packages.wazuh.com/4.x/yum/
|
|
protect=1
|
|
EOF
|
|
|
|
WAZUH_MANAGER="$server_ip" yum install wazuh-agent
|
|
/var/ossec/bin/manage_agents -i $agent_key
|
|
|
|
systemctl daemon-reload
|
|
systemctl enable wazuh-agent
|
|
systemctl start wazuh-agent
|
|
|
|
echo "Desactivando actualizaciones del wazuh-agent"
|
|
sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo
|
|
;;
|
|
|
|
Fedora)
|
|
echo "Distribucion detectada: Fedora"
|
|
echo "Familia principal: RedHat"
|
|
echo "Paqueteria: RPM"
|
|
|
|
rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
|
|
|
|
cat > /etc/yum.repos.d/wazuh.repo << EOF
|
|
[wazuh]
|
|
gpgcheck=1
|
|
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
|
|
enabled=1
|
|
name=EL-\$releasever - Wazuh
|
|
baseurl=https://packages.wazuh.com/4.x/yum/
|
|
protect=1
|
|
EOF
|
|
|
|
WAZUH_MANAGER="$server_ip" yum install wazuh-agent
|
|
/var/ossec/bin/manage_agents -i $agent_key
|
|
|
|
chkconfig --add wazuh-agent
|
|
service wazuh-agent start
|
|
|
|
echo "Desactivando actualizaciones del wazuh-agent"
|
|
sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo
|
|
;;
|
|
|
|
Arch|ManjaroLinux)
|
|
echo "Distribucion detectada: Arch"
|
|
echo "Familia principal: Arch"
|
|
echo "Paqueteria: Sources"
|
|
|
|
pacman -Syu --noconfirm curl gcc make sudo wget expect gnupg perl-base perl fakeroot python brotli automake autoconf libtool gawk libsigsegv nodejs base-devel inetutils cmake
|
|
curl -Ls https://github.com/wazuh/wazuh/archive/v4.4.2.tar.gz | tar zx
|
|
cd wazuh-4.4.2
|
|
./install.sh
|
|
/var/ossec/bin/manage_agents -i $agent_key
|
|
|
|
systemctl daemon-reload
|
|
systemctl enable wazuh-agent
|
|
systemctl start wazuh-agent
|
|
;;
|
|
esac
|