Repository navigation
feat(servers): apply security hardening from the Security tab, with a live log - #71
Merged
agentHits merged 1 commit intoOct 14, 2026
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_HARDENINGset. On a panel without it, Setup Server skipped hardening silently and every item stayed red.What
server.hardenWithLogssubscription:server.executepermission, server access and organization checks, audit entry.write, the same assetupWithLogs.packages/server/src/setup/server-hardening.tsand are used by both Setup Server and the button.DPkg::Lock::Timeout=300), since unattended-upgrades often holds it on a fresh VPS.jail.localexists 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.server-components.tstossh-command.ts, so both modules use it without an import cycle.docs/server-hardening.mddescribes the button and a rollback note for a pre-existingjail.local.Tests
server-hardening.test.ts:bash -nfor every item subset;DOKPLOY_SERVER_HARDENINGstill controls step 15 of Setup Server;jail.localin three cases: created, appended, existing[sshd]kept.packages/serverandapps/dokploypasses. All__test__/server,api,securityandsettingssuites pass locally.🤖 Generated with Claude Code