SERVER HARDENING

One-line hardening for Ubuntu servers โ€” built for Kamal hosts, generic enough for any box.

harden-server.sh

fresh server

Full baseline for a freshly provisioned box:

curl -fsSL https://hardening.bithaiku.com/harden-server.sh | sudo bash

view source ยท configure with env vars, e.g. sudo SSH_PORT=2222 DEPLOY_USER=app bash

harden-existing-server.sh

server already running apps

Same baseline, minus anything that could take production down:

curl -fsSL https://hardening.bithaiku.com/harden-existing-server.sh | sudo bash

view source

auto-updates.sh

updates only

Just unattended security upgrades plus the Sunday-if-required reboot. No firewall, ssh, user, or sysctl changes.

curl -fsSL https://hardening.bithaiku.com/auto-updates.sh | sudo bash

view source

Read before you run. These scripts reconfigure sshd and your firewall. Each is a single top-to-bottom bash file wrapped in main() (a truncated download executes nothing), but you should still look before piping to root:
curl -fsSL https://hardening.bithaiku.com/harden-server.sh -o harden-server.sh less harden-server.sh sudo bash harden-server.sh
And before closing your session afterwards, verify SSH still works from a second terminal.