This skill configures UFW on Ubuntu/Debian to restrict inbound and outbound traffic, reducing attack surface while ensuring essential services remain
npx playbooks add skill mikr13/secure-server-setup-skills --skill firewall-configuration
Configure only the required network paths. Existing active policies and rules must be understood before changing defaults; an allowed SSH rule does not demonstrate that a fresh connection works.
ss -ltnup, effective SSH ports, ssh.socket where present, ufw status verbose, ufw show added, provider security groups and any container-published ports.sshd_config alone./etc/default/ufw IPv6 handling. Include relevant external IPv6 tests; IPv4 filtering cannot establish IPv6 isolation.Read [references/ufw-rules.md](references/ufw-rules.md) for source-restricted rules, routing, Docker and recovery.
Install UFW/iproute2 first if the authorized setup requires them. Preview [scripts/setup-firewall.sh](scripts/setup-firewall.sh):
sudo bash scripts/setup-firewall.sh --ssh-source 203.0.113.10/32 --allow-port 443/tcp --dry-run
For socket/custom listeners, pass each actual port with --ssh-port. Repeat --ssh-source for authorized sources, including IPv6. --public-ssh explicitly chooses access from any source; do not infer that choice from missing information.
Once the rule set and activation are authorized:
sudo bash scripts/setup-firewall.sh --ssh-source 203.0.113.10/32 --allow-port 443/tcp --apply --enable
The helper validates ports/sources/listeners and checks the current SSH client against the proposed source CIDRs before changing rules. If that client is excluded, or its address is unavailable when enabling inactive UFW, it refuses the operation unless --console-recovery-confirmed explicitly attests tested out-of-band recovery. Preserve SSH_CONNECTION through privilege escalation where appropriate; never add the override merely to bypass a failed access check. It adds management access first and snapshots UFW configuration for rollback. It stages deny-incoming/allow-outgoing defaults only on inactive UFW. Existing active defaults and rules are preserved; review unwanted broad allows separately. Without --enable, an inactive firewall remains inactive. Public service flags deliberately allow any source; use manual source-restricted rules for internal databases/services.
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.