From 72a191863cbe52aa5c90e0e41609141cb23d4efb Mon Sep 17 00:00:00 2001 From: buildplan <170122315+buildplan@users.noreply.github.com> Date: Thu, 26 Jun 2025 22:10:35 +0100 Subject: [PATCH] Update setup_harden_debian_ubuntu.sh --- setup_harden_debian_ubuntu.sh | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/setup_harden_debian_ubuntu.sh b/setup_harden_debian_ubuntu.sh index 3ba6c40..6e3da31 100644 --- a/setup_harden_debian_ubuntu.sh +++ b/setup_harden_debian_ubuntu.sh @@ -742,16 +742,10 @@ configure_firewall() { configure_fail2ban() { print_section "Fail2Ban Configuration" - # Collect all SSH ports (main SSH_PORT and any custom ports that are SSH-related) - SSH_PORTS="$SSH_PORT" - if [[ -n "${CUSTOM_PORTS:-}" ]]; then - for port in $CUSTOM_PORTS; do - port_num="${port%%/*}" - if [[ "$port_num" != "$SSH_PORT" && "$port" =~ ^[0-9]+(/tcp)?$ ]]; then - SSH_PORTS="$SSH_PORTS,$port_num" - fi - done - fi + + # Set the SSH port for Fail2Ban to monitor. + local SSH_PORTS_TO_MONITOR="$SSH_PORT" + NEW_FAIL2BAN_CONFIG=$(mktemp) tee "$NEW_FAIL2BAN_CONFIG" > /dev/null <