Skip to content

feat(servers): apply security hardening from the Security tab, with a live log - #71

Merged
agentHits merged 1 commit into
AgentHits-Devfrom
claude-test/dokploy-vps-install-logs-5932c9
Oct 14, 2026
Merged

agentHits merged 1 commit into
AgentHits-Devfrom
claude-test/dokploy-vps-install-logs-5932c9

Conversation

@agentHits

Copy link
Copy Markdown
Owner

Why

The Security tab only showed UFW, SSH and Fail2Ban checks. The hardening script ran only inside Setup Server, and only when the panel had DOKPLOY_SERVER_HARDENING set. On a panel without it, Setup Server skipped hardening silently and every item stayed red.

What

  • Apply hardening button in Setup Server → Security. A dialog with three checkboxes: UFW, SSH keys only, Fail2Ban. Items the check marked red are preselected.
    • The SSH item shows a warning that password login stops working for everyone.
    • The UFW item notes that Docker-published ports bypass UFW, and lists the swarm ports to open for multi-node swarms.
  • Live log in the dialog. It is also saved as a "Security hardening" deployment of the server (Settings → Deployments). The check refreshes when the run finishes.
  • server.hardenWithLogs subscription:
    • server.execute permission, server access and organization checks, audit entry.
    • Items are validated against a fixed enum.
    • Classified as write, the same as setupWithLogs.
  • Shared commands: the hardening commands moved to packages/server/src/setup/server-hardening.ts and are used by both Setup Server and the button.
  • Standalone script: checks for root or passwordless sudo and refreshes apt lists first.
  • apt lock: apt waits up to 5 minutes for its lock (DPkg::Lock::Timeout=300), since unattended-upgrades often holds it on a fresh VPS.
  • Fail2Ban: if jail.local exists but has no [sshd] section, the section is appended. Before, the step was skipped and the check stayed red. An existing [sshd] section is still left unchanged.
  • SSH runner: moved from server-components.ts to ssh-command.ts, so both modules use it without an import cycle.
  • Ports: UFW opens SSH and 443 tcp/udp only. Port 80 stays closed.
  • Docs: docs/server-hardening.md describes the button and a rollback note for a pre-existing jail.local.

Tests

  • server-hardening.test.ts:
    • the script passes bash -n for every item subset;
    • only the selected items are included;
    • port 80 is never opened;
    • the script stops without root or passwordless sudo;
    • DOKPLOY_SERVER_HARDENING still controls step 15 of Setup Server;
    • the Fail2Ban step runs against a temporary jail.local in three cases: created, appended, existing [sshd] kept.
  • Router: an inaccessible server is rejected before any side effect, and unknown items are rejected.
  • Typecheck of packages/server and apps/dokploy passes. All __test__/server, api, security and settings suites pass locally.
  • Not run yet: a real hardening run against a VPS from the UI. That needs this image deployed.

🤖 Generated with Claude Code

… live log

The Security tab only showed UFW, SSH and Fail2Ban checks. The hardening
script ran only inside Setup Server, and only when the panel had
DOKPLOY_SERVER_HARDENING set, so on most servers it was skipped silently.

The tab now has an "Apply hardening" button. It opens a dialog with three
checkboxes (UFW, SSH keys only, Fail2Ban); the items the check marked red
are preselected. The script runs over SSH, the log streams into the dialog
and is saved as a "Security hardening" deployment of the server, and the
check refreshes when it finishes.

- New server.hardenWithLogs subscription: server.execute permission,
  server access and organization checks, audit entry, items limited to
  the known list. Classified as "write", like setupWithLogs.
- Hardening commands moved from server-setup.ts to server-hardening.ts and
  shared by Setup Server and the button. The standalone script checks for
  root or passwordless sudo and refreshes apt lists first.
- apt waits up to 5 minutes for its lock, since unattended-upgrades often
  holds it on a fresh VPS.
- Fail2Ban appends an [sshd] section to an existing jail.local that has
  none, instead of skipping it, so the check can turn green. An existing
  [sshd] section is still left alone.
- The SSH runner moved from server-components.ts to ssh-command.ts so both
  modules use it without an import cycle.
- UFW opens SSH and 443 tcp/udp only; port 80 stays closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@agentHits
agentHits merged commit 088bcf0 into AgentHits-Dev Oct 14, 2026
7 checks passed
@agentHits
agentHits deleted the claude-test/dokploy-vps-install-logs-5932c9 branch October 14, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant