fix(harden): backend-neutral firewall wording; skip iptables sshguard jump on firewalld
The harden scripts logged 'deny-by-default INPUT; carries the sshguard jump' even on Alma, where the firewall is firewalld (no INPUT chain, no jump). Make the message backend-neutral, and when ENABLE_FIREWALL=0 on rhel skip the iptables boot-hook entirely -- sshguard's firewalld backend manages its own ipset blocks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -307,11 +307,16 @@ EOF
|
||||
# hook that just (re)inserts the jump at every boot.
|
||||
: "${ENABLE_FIREWALL:=1}"
|
||||
if [[ "$ENABLE_FIREWALL" == "1" && -f "$SCRIPT_DIR/harden-firewall.sh" ]]; then
|
||||
log "Installing host firewall (deny-by-default INPUT; carries the sshguard jump)..."
|
||||
log "Installing host firewall (deny-by-default; iptables or firewalld per OS)..."
|
||||
SSH_PORT="$SSH_PORT" OPEN_PORTS="${OPEN_PORTS:-}" \
|
||||
FW_SSH_SOURCE="${FW_SSH_SOURCE:-}" FW_ALLOW_PING="${FW_ALLOW_PING:-1}" \
|
||||
FORCE=1 bash "$SCRIPT_DIR/harden-firewall.sh" apply \
|
||||
|| warn "harden-firewall.sh failed; INPUT left unfiltered. Re-run it manually."
|
||||
|| warn "harden-firewall.sh failed; host firewall not applied. Re-run it manually."
|
||||
elif [[ "$OS_FAMILY" == rhel ]]; then
|
||||
# On Alma/RHEL sshguard uses its firewalld backend (sshg-fw-firewalld) and
|
||||
# manages its own firewalld ipset blocks -- there is no iptables INPUT->sshguard
|
||||
# jump to add, so skip the boot hook.
|
||||
warn "Host firewall disabled; sshguard manages firewalld directly (no iptables jump)."
|
||||
else
|
||||
HOOK=$(mktemp)
|
||||
cat > "$HOOK" <<'EOF'
|
||||
|
||||
@@ -286,11 +286,16 @@ EOF
|
||||
# hook that just (re)inserts the jump at every boot.
|
||||
: "${ENABLE_FIREWALL:=1}"
|
||||
if [[ "$ENABLE_FIREWALL" == "1" && -f "$SCRIPT_DIR/harden-firewall.sh" ]]; then
|
||||
log "Installing host firewall (deny-by-default INPUT; carries the sshguard jump)..."
|
||||
log "Installing host firewall (deny-by-default; iptables or firewalld per OS)..."
|
||||
SSH_PORT="$SSH_PORT" OPEN_PORTS="${OPEN_PORTS:-}" \
|
||||
FW_SSH_SOURCE="${FW_SSH_SOURCE:-}" FW_ALLOW_PING="${FW_ALLOW_PING:-1}" \
|
||||
FORCE=1 bash "$SCRIPT_DIR/harden-firewall.sh" apply \
|
||||
|| warn "harden-firewall.sh failed; INPUT left unfiltered. Re-run it manually."
|
||||
|| warn "harden-firewall.sh failed; host firewall not applied. Re-run it manually."
|
||||
elif [[ "$OS_FAMILY" == rhel ]]; then
|
||||
# On Alma/RHEL sshguard uses its firewalld backend (sshg-fw-firewalld) and
|
||||
# manages its own firewalld ipset blocks -- there is no iptables INPUT->sshguard
|
||||
# jump to add, so skip the boot hook.
|
||||
warn "Host firewall disabled; sshguard manages firewalld directly (no iptables jump)."
|
||||
else
|
||||
HOOK=$(mktemp)
|
||||
cat > "$HOOK" <<'EOF'
|
||||
|
||||
Reference in New Issue
Block a user