From 26ae76bfbf7410f2e92d9794bb1ad5cd3a8a806e Mon Sep 17 00:00:00 2001 From: RaspbianProyect by HP3ICC Date: Sat, 3 Jun 2023 07:07:00 +0000 Subject: [PATCH] Update f2b+ufw.sh --- install/f2b+ufw.sh | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/install/f2b+ufw.sh b/install/f2b+ufw.sh index 610b797..9629b73 100644 --- a/install/f2b+ufw.sh +++ b/install/f2b+ufw.sh @@ -1,5 +1,4 @@ - if systemctl status iptables-persistent |grep active >/dev/null 2>&1 then sudo systemctl stop iptables-persistent @@ -14,7 +13,19 @@ then fi #ufw -sudo apt install ufw -y +apps=("ufw") + +for app in "${apps[@]}" +do + # Verificar apps + if ! dpkg -s "$app" >/dev/null 2>&1; then + # app no instalada + sudo apt-get install -y "$app" + else + # app ya instalada + echo "$app ya instalada" + fi +done sudo ufw allow 22/tcp sudo ufw default deny incoming @@ -26,7 +37,19 @@ rm /var/log/auth.log sudo systemctl enable rsyslog sudo systemctl restart rsyslog -sudo apt install fail2ban -y +apps=("fail2ban") + +for app in "${apps[@]}" +do + # Verificar apps + if ! dpkg -s "$app" >/dev/null 2>&1; then + # app no instalada + sudo apt-get install -y "$app" + else + # app ya instalada + echo "$app ya instalada" + fi +done cat > /etc/fail2ban/jail.local <<- "EOF" [sshd]