Skip to content

Installing CSF on cPanel and writing a baseline that does not lock you out

A safe install path for ConfigServer Security & Firewall on a cPanel host — testing mode, the right ports, and the LFD settings that work without filling your inbox.

Every operator who installs CSF for the first time eventually locks themselves out of SSH. Once. Then they never forget the testing-mode flag again. CSF on cPanel is straightforward to install — the value is in the baseline config, which determines whether the firewall protects you or just frustrates you.

What’s happening

CSF is two daemons: csf is the iptables/nftables ruleset manager, lfd is the login-failure-detection daemon that watches log files for brute force and writes temporary blocks. cPanel does not ship CSF — you install it from configserver.com. The defaults are conservative and useful, but a handful of values must be edited before reload.

How to verify

csf --version
csf -l | head -20
csf -t
lfd --status
grep -E "^(TESTING|TCP_IN|TCP_OUT|DENY_IP_LIMIT) " /etc/csf/csf.conf

csf -t shows temporary blocks. csf -l shows current iptables rules.

The fix

  1. Install via the configserver.com tarball into /etc/csf/. Run csftest.pl to confirm the kernel supports the required modules.
  2. Edit /etc/csf/csf.conf before first reload:
    • TESTING = 1 (yes, leave testing mode on for the first 24h)
    • TCP_IN and TCP_OUT: include 20,21,22,25,53,80,110,143,443,465,587,993,995,2078,2079,2080,2082,2083,2086,2087,2089,2095,2096
    • RESTRICT_SYSLOG = 3 to prevent log spoofing
    • CC_DENY empty initially — country blocking is opinionated, leave it for week two
  3. Run csf -r to reload. Confirm you can still SSH in from a second window before going further.
  4. Flip TESTING = 0 after 24 hours of clean behavior.
  5. LFD baseline: LF_TRIGGER = 5, LF_SSHD = 5, LF_FTPD = 10, LF_CPANEL = 5. Add LF_ALERT_TO = ops@yourdomain and LF_ALERT_FROM = lfd@yourhost so you actually see notifications.
  6. Whitelist your management IPs in /etc/csf/csf.allow before anything else, and document them.

Stack Harbor installs and maintains CSF baselines as part of cPanel server management.