CSF (ConfigServer Security & Firewall) doing exactly what you told it to do is the classic admin mistake: enable deny-by-default with TESTING = 0 and an empty allow list, and SSH closes on you mid-edit. The console-level recovery is straightforward if you have provider console access; without it, the path requires a single-user-mode boot or KVM. Either way, the lesson is that CSF has a testing mode for a reason.
What’s happening
CSF runs as an iptables/nftables ruleset. When TESTING = 1 in /etc/csf/csf.conf, the rules expire after 5 minutes — exactly so you cannot lock yourself out. When TESTING = 0, the rules persist across reboots. If your allow list does not include your IP and the deny default is in place, you cannot SSH back in. CSF also has LFD (Login Failure Daemon) which can auto-ban an IP after failed logins, and that ban survives reboot.
How to verify
If you can still get a console (provider KVM, hypervisor console), check what CSF is doing:
csf -l # list current rules
cat /etc/csf/csf.conf | grep -E "^TESTING|^DENY_IP_LIMIT"
cat /etc/csf/csf.allow
cat /etc/csf/csf.deny
csf -t # active temp blocks (LFD)
journalctl -u lfd --since "1 hour ago"
# is your IP banned?
csf -g <your-ip>
If you cannot get a console at all, the provider’s “console access” or “rescue mode” is the next step.
The fix
- Console-only access — through the provider console, log in as root.
csf -df <your-ip>to remove an LFD temp ban for your IP,csf -a <your-ip>to permanently allow. - Stop CSF temporarily —
csf -x(disable) restores connectivity immediately while you fix the config. SSH back in via your normal path, edit/etc/csf/csf.conf, re-enable withcsf -e. - Rescue mode if no console — boot the server in rescue mode, mount the root filesystem, edit
/etc/csf/csf.allowto add your IP. Or simpler: rename/etc/csf/csf.denyto disable all deny rules on next boot. - Re-enable TESTING mode for next change —
TESTING = 1incsf.conf, thencsf -r. Future changes will time out after 5 minutes if they break connectivity, restoring access automatically. - Document the allow list — write down which IPs are in
csf.allow, why, and when they were added. CSF’s allow list grows incoherent over years; a comment per line helps future you.
The same pattern applies to nftables/iptables changes outside CSF — never change a deny-default firewall on a server you cannot get console to. Stack Harbor handles firewall change windows with rollback under WHM server management — start a conversation for the next CSF policy review.