From dc4e84172e8ec2c21c4ab729b716f7b7a2014395 Mon Sep 17 00:00:00 2001 From: Kobe Wijnants Date: Fri, 2 Aug 2024 16:19:20 +0200 Subject: [PATCH] Fix ufw firewall script --- src/commands/security/firewall-baselines.sh | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/commands/security/firewall-baselines.sh b/src/commands/security/firewall-baselines.sh index b6153065..0b0888de 100644 --- a/src/commands/security/firewall-baselines.sh +++ b/src/commands/security/firewall-baselines.sh @@ -1,5 +1,7 @@ #!/bin/sh -e +. ./common-script.sh + installPkg() { echo "Install UFW if not already installed..." if ! command_exists ufw; then @@ -14,26 +16,33 @@ installPkg() { else echo "UFW is already installed." fi +} + +configureUFW() { echo -e "${GREEN}Using Chris Titus Recommended Firewall Rules${RC}" - sudo ufw limit 22/tcp + + echo "Disabling UFW" + sudo ufw disable + echo "Limiting port 22/tcp (UFW)" + sudo ufw limit 22/tcp - sudo ufw allow 80/tcp echo "Allowing port 80/tcp (UFW)" + sudo ufw allow 80/tcp - sudo ufw allow 443/tcp echo "Allowing port 443/tcp (UFW)" + sudo ufw allow 443/tcp - sudo ufw default deny incoming echo "Denying Incoming Packets by Default(UFW)" + sudo ufw default deny incoming - sudo ufw default allow outgoing echo "Allowing Outcoming Packets by Default(UFW)" + sudo ufw default allow outgoing - sudo ufw enable echo -e "${GREEN}Enabled Firewall with Baselines!${RC}" - + sudo ufw enable } checkEnv installPkg +configureUFW