|
| 1 | +# VPS-Harden |
| 2 | + |
| 3 | +> Idempotent Bash script to harden a Debian/Ubuntu VPS. One script, zero dependencies, dry-run first, lockout protection built in. |
| 4 | + |
| 5 | +VPS-Harden is a single Bash script that secures a fresh or existing Debian/Ubuntu server. It runs 14 modules covering SSH hardening, firewall (UFW), fail2ban, kernel sysctl hardening, Netbird mesh VPN, SOPS+age secrets management, auditd monitoring, unattended upgrades, and more. |
| 6 | + |
| 7 | +Key properties: |
| 8 | +- Idempotent: checks current state before every action, safe to re-run anytime |
| 9 | +- Dry-run mode: preview every change before applying |
| 10 | +- Lockout protection: validates sshd config, SSH keys, AllowUsers, and firewall rules before restarting — auto-rolls back on failure |
| 11 | +- Interactive wizard: run `sudo vps-harden` with no args for guided setup with auto-detection |
| 12 | +- Security scorecard: grouped verification output with section headers and next-steps guidance |
| 13 | +- Zero dependencies: single Bash file, no Python, no Ansible, no agents |
| 14 | + |
| 15 | +Install: `curl -fsSL https://raw.githubusercontent.com/ranjith-src/vps-harden/main/install.sh | bash` |
| 16 | + |
| 17 | +## Documentation |
| 18 | + |
| 19 | +- [README](https://github.com/ranjith-src/vps-harden/blob/main/README.md): Full parameter reference, module table, scorecard example, config file format |
| 20 | +- [Getting Started Guide](https://github.com/ranjith-src/vps-harden/blob/main/docs/getting-started.md): Step-by-step onboarding from first SSH login to fully verified setup |
| 21 | +- [Contributing](https://github.com/ranjith-src/vps-harden/blob/main/CONTRIBUTING.md): How to add modules, code style, ShellCheck requirements |
| 22 | +- [Releases](https://github.com/ranjith-src/vps-harden/releases): Changelog for each version |
| 23 | + |
| 24 | +## Modules |
| 25 | + |
| 26 | +- prereqs: Installs foundation packages (curl, wget, jq, htop, ufw, fail2ban) |
| 27 | +- user: Creates non-root user with sudo access, deploys SSH keys |
| 28 | +- ssh: Disables root login, disables password auth, MaxAuthTries 3, AllowUsers, banner |
| 29 | +- firewall: UFW default-deny incoming, allow outgoing, allow SSH |
| 30 | +- fail2ban: 3 retries, 3h ban, UFW integration |
| 31 | +- sysctl: SYN cookies, disable ICMP redirects/source routing, martian logging, RP filtering |
| 32 | +- netbird: Installs Netbird mesh VPN, connects with setup key |
| 33 | +- firewall_tighten: Allows VPN tunnel traffic, restricts SSH to safety IP, removes broad rules |
| 34 | +- sops: Installs SOPS + age, generates encryption keypair |
| 35 | +- upgrades: Enables unattended-upgrades, optional auto-reboot |
| 36 | +- monitoring: Installs auditd + logwatch, deploys audit rules, installs server-report CLI |
| 37 | +- shell: umask 027, bash history with timestamps, plaintext secret scanning |
| 38 | +- misc: Timezone, hostname, lock root password, restrict su |
| 39 | +- verify: Runs all checks, prints grouped security scorecard with next steps |
| 40 | + |
| 41 | +## Optional |
| 42 | + |
| 43 | +- [server-report](https://github.com/ranjith-src/vps-harden/blob/main/server-report): Companion CLI for quick VPS health checks (summary, auth, audit, full subcommands) |
| 44 | +- [Config example](https://github.com/ranjith-src/vps-harden/blob/main/examples/config.env): Sample KEY=VALUE config file for repeatable setups |
0 commit comments