Skip to content
Security Harden a server — firewall, SSH, Fail2ban, bans and malware scanning — with a live hardening score.

Security

The Security section of a server (/servers/:id/security) is where you harden the box and keep it that way: a UFW firewall, SSH hardening, Fail2ban jails and bans, malware and integrity scans, and a live hardening score that tells you what’s still open. Everything here — including the per-site managed WAF — is on all plans.

The page is a tabbed hub — Overview, Scan, Firewall, SSH, Fail2ban and Bans — reading its state live from the agent and writing every change back as a real job.

  1. Open Overview. The Hardening score ring shows how many checks pass: firewall active, SSH key-only login, root SSH login disabled, Fail2ban protecting SSH, automatic security updates, (optional) SSH on a non-standard port, and the coverage checks read from the box’s inventory: WAF engine installed (ModSecurity), Malware scanner (ClamAV), Sites isolated (N/M) (sites on their own sandboxed PHP-FPM) and Site shells jailed (N/M) (site users with a login shell). A coverage check only appears when its data is known; misses count as recommendations (amber).
  2. Each failing check has a one-click fix inline — Enable the firewall, switch SSH to key-only, Disable root login, Enable the sshd jail, Install the WAF (Extensions) or ClamAV (Scan tab), or Review sites and users. Automatic security updates are changed in Settings → Updates & reboots (the check’s Configure opens it). The score and posture tiles update as each one applies.
  3. Passing checks become links that jump you into the matching tab (Firewall, SSH, Fail2ban) to review or fine-tune the details.
  4. Watch Recent login attempts at the bottom — real SSH successes and failures from the box’s journal, with a link into Logs for the full history.
  • Firewall — the host firewall’s rules (UFW on Ubuntu/Debian, firewalld on AlmaLinux/Rocky; the tab names the one the box runs, and says so when none is installed) as list cards you can filter (All / Allow / Deny) and search; add or edit a rule (port, protocol, action, source IP/CIDR, comment) in a drawer, delete rules, and toggle the whole firewall on or off.
  • SSH — harden sshd: key-only auth, root login on/off, the listen port, and an Allowed users (AllowUsers) allow-list that governs both SSH and SFTP.
  • Fail2ban — each jail (sshd, nginx-badbots, wordpress, recidive…) is a card you can enable/disable and tune (maxretry, findtime, bantime).
  • Bans — the live ban list per jail, unban an address, or add a manual ban.
  • Scan — three on-demand scans: a Malware scan (ClamAV over a content root, with quarantine/delete on each finding), a WordPress integrity check (core & plugin files against wordpress.org checksums, per site), and a rogue vhost scan that flags Nginx server blocks MZPanel didn’t create and lets you disable them (a sites-enabled entry moves to /etc/nginx/mz-disabled; a conf.d file, the vhost folder on AlmaLinux/Rocky, is renamed to <name>.conf.disabled; both after an nginx -t check, and both reversible).
  • Tools (top-right) — Export the firewall/SSH/Fail2ban/auto-updates config as JSON, Import a JSON file onto this server, Copy settings to another server, and Re-scan the posture (the agent re-reads firewall, SSH and Fail2ban now). See Import settings or copy them to other servers.

Import settings or copy them to other servers

Section titled “Import settings or copy them to other servers”

Export writes this server’s firewall rules, firewall on/off, SSH (port, root login, key-only, AllowUsers), Fail2ban jails and automatic updates to a JSON file (format: "mzpanel.security/1"). Import reads such a file and Copy settings to another server sends this server’s settings to the servers you pick. Both work the same way:

  1. Each target server is compared with its own current state, and you see a diff (current → incoming) before anything runs. Nothing is applied until you press Apply (or Copy to N) and then Confirm.
  2. The changes run as ordinary jobs, one at a time: security.fw, security.fw-toggle, security.ssh-allow, security.ssh, security.f2b, security.f2b-config and security.auto-updates. A failed job stops that server’s run; with Copy, the next server still runs. Each server shows its own status.
  3. Firewall and SSH changes use a 5-minute auto-revert window: open a new SSH session, then press Keep these changes (per server in the Copy drawer). See Risky changes revert unless you confirm them.

Safeguards that always apply:

  • The firewall rule that lets the server’s current SSH port in is never removed, and no deny or reject from Anywhere on that port is added.
  • Before the firewall is turned on, or SSH moves to another port, the SSH port is opened first. The old port’s rule stays.
  • Password login is turned off (key-only) only when the server has an authorized SSH key, and root login only when a non-root user has a key.
  • Keep current SSH access (on by default) also holds back the SSH port, root login off, key-only, a new AllowUsers list and AllowUsers removals. Turn it off to apply those.
  • Remove rules not in the file is off by default: only the file’s rules are added.
  • A change that would drop a rule naming a protected IP (your browser’s IP, or an IP that logged in over SSH recently) needs an extra tick (“I have another way into this server”).
  • Held-back and blocked items are listed in the diff with the reason. Jails the target doesn’t have, and limit or app-profile firewall rules, are skipped. The agent handles the ufw/firewalld difference.

Risky changes revert unless you confirm them

Section titled “Risky changes revert unless you confirm them”

A firewall or SSH change can lock you out of SSH. So when a change can do that, MZPanel applies it and then gives you 2 minutes to prove you still have access. If you don’t confirm in time, the server puts the previous settings back on its own.

A change counts as risky when the firewall is on and it closes the SSH port (a deny or reject rule that covers it, or removing the allow rule for it), when it turns the firewall on, when it moves the SSH port, turns on key-only login, turns root login off, or makes the Allowed users list narrower. Opening a port, turning the firewall off or adding a user to an existing allow-list apply as before, with no countdown.

  1. Make the change in the Firewall or SSH tab.
  2. A yellow banner appears with a countdown and the pending change.
  3. Open a new SSH session to the server (keep the old one open). If it works, click Keep these changes.
  4. If you can’t get in, do nothing. When the countdown ends the server restores the previous firewall rules and sshd settings and reloads them.

Several risky changes in a row share one countdown: the timer restarts and Keep these changes keeps all of them (a revert undoes all of them).

Nothing confirms on its own, on purpose. The agent’s connection to MZPanel is outbound, so the agent staying online doesn’t prove you can still open SSH.

The countdown runs on the server as a systemd timer, so it still fires if the agent is restarting or the connection to MZPanel drops. If the server reboots during the window, the agent restores the previous settings when it starts (or re-arms the timer if time is left). Needs agent 0.2.159 or newer; older agents apply the change with no countdown.

Open your provider’s web console (VNC / serial) and run, as root:

Terminal window
mzagent rescue all --dry-run # show what it would restore, change nothing
mzagent rescue all # or: rescue firewall / rescue ssh

For each part it restores the snapshot of a change you never confirmed, else the last known-good state (saved when a change was confirmed or reverted). With no snapshot it applies safe defaults: it adds allow rules for TCP 22, your SSH port, 80 and 443 (it never deletes rules), sets the panel’s SSH allow-list file aside (*.rescued), and only when no authorized key exists on the box removes the panel’s PasswordAuthentication override so the distro default applies. --safe-default skips the snapshots.

Every write dispatches a real security.* (or waf.*) job to the agent, which runs it natively — no shell-out to mz, the same engine the CLI uses. After each job the panel refetches the security inventory, which is the source of truth.

AreaJob kindAgent runs
Firewall rule add/removesecurity.fwufw allow/deny + reload
Firewall on/offsecurity.fw-toggleufw enable/disable
SSH hardeningsecurity.sshwrites /etc/ssh/sshd_config.d/00-mz-hardening.conf
SSH allow-listsecurity.ssh-allowwrites 00-mz-allowusers.conf
Keep a risky changesecurity.confirmstops the revert timer, drops the snapshot
Jail enable/configsecurity.f2b, security.f2b-configdrop-in under /etc/fail2ban/jail.d + reload
Ban / unbansecurity.f2bfail2ban-client ban/unban
Auto updatessecurity.auto-updatesunattended-upgrades config
Malware scansecurity.scan, security.fileclamscan; quarantine to /opt/mzpanel/quarantine
WP integritysecurity.wp-integritywp core/plugin verify-checksums
Rogue vhostsecurity.rogue-vhost, security.vhost-disablereads Nginx provenance; quarantines a vhost

The read side — UFW rules, effective sshd config, Fail2ban jails and bans, auto-update status and recent login attempts — comes from the agent-pushed security inventory, so the page also renders the last-known state when the server is offline.

Beyond the box-level firewall, MZPanel offers a managed WAF — ModSecurity with the OWASP Core Rule Set in front of your sites, blocking SQL injection, XSS, LFI, RCE and more at Nginx. It is on all plans (ModSecurity is a Free extension; the site’s Firewall panel offers to install it first) and is managed per site, not per box: open Sites → Manage → Security → Firewall. The same Security hub has a per-site Malware scan (ClamAV over the site’s docroot) and, for WordPress sites only, Integrity (core/plugin checksums). Enable the WAF where you need it and leave low-risk sites alone.

The WAF runs in one of three modes:

Jobs: waf.status, waf.enable {domain, mode?: learning|blocking}, waf.mode {domain, mode: off|learning|blocking}, waf.disable.

ModeCLI nameBehavior
OffoffNo inspection.
Detect (learning)learningMatches are logged only — traffic passes.
BlockblockingMalicious requests are rejected with 403.

Every WordPress site gets a guard against password guessing on wp-login.php and xmlrpc.php — no setup, no WAF needed. These paths skip the page cache, so a single bot can otherwise pin every CPU core.

LayerWhat it does
xmlrpc.php blockedAnswered with 403 before PHP runs. Default for every WordPress site.
Login rate limitwp-login.php: 12 requests/min per IP (burst 20), then 429.
Fail2ban mz-wp-auth30 failed login/xmlrpc attempts in 10 minutes → the IP is banned at the firewall for 1 hour, longer for repeat offenders. Shows in the Bans table.

Behind Cloudflare the guard sees the real visitor IP, and Cloudflare’s own ranges are never banned. The guard is applied to new sites at creation and to existing sites when the agent starts (agent releases after 0.2.141).

Using Jetpack or the WordPress mobile app? They need xmlrpc. Re-allow it per site (it stays rate-limited to 60 requests/min per IP): open the site, Security → Firewall, and turn on Allow XML-RPC (Jetpack, mobile app) in the Brute-force guard card (needs agent 0.2.142 or newer; older agents show an “update the agent” hint). On the box:

Terminal window
mz site wp-guard example.com --xmlrpc allow --json # deny = back to the default
mz site wp-guard example.com --json # show the state

Every action here maps to an mz command on the box — the same engine the dashboard drives:

Terminal window
mz security fw enable --json # turn the firewall on
mz security fw add 443 tcp allow '' HTTPS --json # allow a port
mz security ssh-set --key-only 1 --permit-root 0 --json
mz security ssh-set --port 2222 --revert-in 120 --json # revert in 120 s unless confirmed
mz security confirm <id> --json # keep it (id from the result)
mz security f2b ban sshd 203.0.113.50 --json # ban an IP in a jail
mz security scan /home --json # ClamAV scan a content root
mz waf mode example.com blocking # per-site WAF: off|learning|blocking
mz site wp-guard example.com --xmlrpc allow --json # WordPress guard: re-allow xmlrpc
mz site cf-only example.com --on --json # only accept traffic through Cloudflare
mz site harden --json # re-apply hardening + WP guard to every site

Pass --json for machine output. See The mz CLI and the command catalog.

GoalMCP toolJob kind
Read posture (rules, sshd, jails, bans, auto-updates)servers_inventory with kind security—
Firewall rule / on-offjobs_createsecurity.fw, security.fw-toggle
SSH hardening / allow-listjobs_createsecurity.ssh, security.ssh-allow
Keep a risky firewall/SSH change (stop its auto-revert)jobs_createsecurity.confirm {id}
Fail2ban jails, bansjobs_createsecurity.f2b, security.f2b-config
Malware scan / WP integrityjobs_createsecurity.scan {path?}, security.wp-integrity {domain}
Per-site WAFjobs_createwaf.status, waf.enable, waf.mode, waf.disable
Cloudflare only: refuse requests that bypass Cloudflare (any site type, Docker apps)jobs_createsite.cf-only {domain, mode?}, app.cf-only {name, mode?}; see DNS & TLS
WordPress brute-force guard: read state / allow or block XML-RPCjobs_createsite.wp-guard {domain} (read, also repairs a missing guard), site.wp-guard {domain, xmlrpc: "allow" | "deny"}

Firewall, SSH, security.file (quarantine/delete) and reboots are guarded: a token needs full level plus the system:admin scope (files:write for security.file); waf.enable/waf.disable need full; site.wp-guard needs operate. Call jobs_schema for each body.

security.fw, security.fw-toggle, security.ssh and security.ssh-allow take confirmWithin (30–600 seconds, default 120) and noRevert: true. When a change is risky, the job result has a revert object (id, expires_at, changes) and the security inventory shows it as pending_revert until it is confirmed or reverted. Have the human check a new SSH session, then send security.confirm {id} (scope system:admin). A confirm after the deadline fails with already_reverted; an unknown id with not_found. site.wp-guard works on WordPress sites only (other sites fail with not_wordpress) and needs agent 0.2.142 or newer (older agents exit 127).

  • Live, with an offline fallback. Firewall, SSH, Fail2ban and scans run real jobs while the agent is online. Offline, the page shows the last-known state from cache and changes are disabled until the agent reconnects.
  • The Bans table is sparse on some fields. IP and jail come straight from Fail2ban; the failure count, country and ban time aren’t populated from the live inventory yet, so those columns can read blank.
  • Import and Copy need the target online and its security state reported. An offline server is skipped; a server that never reported its state shows “No security state reported”. There is no single “copy” job: automate it with the security.* jobs listed above, read the target first with servers_inventory {id, kind: "security"}.
  • “Last scanned” is when the agent last reported. Re-scan asks the agent to re-push the security snapshot (it needs the agent online); malware and integrity scans live under the Scan tab.
  • Scheduled malware scans aren’t shipped. On-demand ClamAV scanning and quarantine work today; recurring maldet-style signature sweeps are planned but not yet available.
  • A bot keeps going after you block its IP in the firewall. The firewall does not close connections that are already open. In the terminal run ss -K dst <ip> after adding the rule (Fail2ban bans already drop them).
  • Locking yourself out of SSH. Switching to key-only with no key installed is refused, the allow-list op always keeps root, and every risky change reverts after 2 minutes unless you click Keep these changes (see above). If you are locked out anyway, run mzagent rescue all from the provider’s console.
  • The banner says “Restoring the previous settings”. The countdown ran out without a confirm. Make the change again and confirm it within the window.