Harden a fresh Debian VPS: SSH, fail2ban, UFW, BBR, unattended-upgrades. One command.
README.md

VPS Setup Tool #

→ View the live site

Provision and harden a fresh Debian 13 VPS in one command. No app included - bring your own. This is the scaffolding layer.

What it does #

setup.sh (runs on your machine):

  1. Verifies SSH reachability
  2. Waits for cloud-init to finish
  3. Forces DNS to public resolvers, swaps apt sources, installs base tools
  4. Uploads bootstrap.sh + harden.sh to the target
  5. Runs them in order

bootstrap.sh (runs on the VPS):

  • Installs nginx, ufw, fail2ban, unattended-upgrades, python3, git, curl, wget, rsync, ca-certificates, sqlite3
  • Generates an nginx security-headers snippet (HSTS, CSP, COOP/CORP, etc.) and a dotfile-deny rule that leaves /.well-known/ reachable
  • Creates /var/www/acme and adds a location ^~ /.well-known/acme-challenge/ block, so ACME HTTP-01 challenges (certbot, acme.sh, lego) resolve without editing nginx
  • Generates a placeholder nginx site - either a static 200 or a reverse proxy to a configurable port
  • Generates a skeleton systemd unit template at /etc/systemd/system/app.service.template
  • Enables the site, verifies nginx -t

harden.sh (runs on the VPS):

  • SSH daemon hardening (drop-in 00-hardening.conf)
  • ssh-audit cipher/KEX/MAC hardening
  • MOTD + LastLog suppression
  • fail2ban (sshd aggressive + recidive jail, UFW banaction)
  • sysctl: kernel hardening + BBR + fq + TCP tuning
  • unattended-upgrades
  • UFW: deny in, allow 22/80/443, rate-limit 22

Requirements #

  • Target: fresh Debian 13 (trixie) or similar
  • Root SSH access with authorized_keys populated
  • Local: bash, rsync, ssh, tar

Usage #

bash setup.sh [options] <ssh-target>