>_ vps-bootstrap
Debian 12/13+ & Ubuntu 22.04/24.04+ Interactive · Config · Dry-Run MIT

Reproducible VPS Bootstrap & Hardening

One audited Bash entrypoint to provision fresh Debian and Ubuntu servers: sudo & deploy users, first-match-wins SSH hardening, UFW or nftables, Fail2ban, DST-aware unattended upgrades, BBR, zram, and journald caps.

Run as root on a fresh Debian/Ubuntu VPS (interactive prompts + Cloudflare-hosted lang packs):
$ bash <(curl -fsSL 'https://vps-bootstrap.pages.dev/vps-setup.sh')
Tip: Keep -fsSL so curl follows HTTP redirects (-L) and fails on HTTP errors (-f). Non-root sudo users should use curl -fsSLO + sudo bash vps-setup.sh (since sudo closes /dev/fd/*).

Execution Pipeline

Runs in a predictable, idempotent sequence after plan confirmation (or preview with --dry-run).

01APT & CLI Tools
02Timezone & NTP
03Users & Sudoers
04SSH Hardening
05Firewall
06Fail2ban
07Auto Upgrades
08BBR & TCP Tiers
09Zram Compression
10Disk Swap
11Journald & Logs
12Verify Report

Built for Real Cloud & KVM VPS Environments

Guards against cloud-init drop-in shadowing, provider sysctl overrides, container constraints, and lockout.

SSH & Users

Lockout-Safe SSH Hardening

Auto-detects debian/ubuntu admin user and optional deploy user. Validates keys via ssh-keygen before disabling passwords, writes 00-vps-hardening.conf, places Include first, updates ssh.socket, and checks sshd -T.

Firewall & IPS

UFW, nftables & Fail2ban

Choose ufw, a dual-stack /etc/nftables.conf ruleset (nftables-setup), nftables-keep, or none. Fail2ban uses backend = systemd and switches to nftables[type=multiport] automatically in nftables modes.

Maintenance

Timezone-Converted Upgrades

Configures unattended-upgrades (origin=*, unused kernel cleanup, auto-reboot) and converts your reference window (default 04:00–05:30 Asia/Singapore) into server local time with pre-run DST adjustment.

Network

BBR & RAM-Tiered TCP

Enables TCP BBR with fq_codel (or fq) and scales rmem_max/wmem_max/nf_conntrack_max across four RAM tiers inside 99-zzz-network-tuning.conf so provider configs stay overridden.

Memory & Disk

Zram, Swap & Log Caps

Sets up Fedora-style zram (systemd-zram-generator / zram-tools, lz4, min(ram*1.0, 4096)), idempotent swapfile (skipped in containers), smart vm.swappiness, and 50M journald + 10M logrotate limits.

Automation & i18n

Config Parser & Lang Packs

Parses vps.conf and .lang files without source/eval. Fetches zh-cn.lang from Cloudflare Pages (with GitHub Raw fallback) or local ./lang/, plus optional GeoIP timezone detection and chrony-safe NTP.

Presets (preset/)

Fetch curated defaults dynamically with --preset <name> (Cloudflare Pages primary, GitHub Raw fallback) and override any flag via --config or CLI.

--preset recommended

Recommended Hardened Preset

Answers "yes" to all recommended hardening, package, tuning, and maintenance options without stepping through 20+ prompts—leaving only the three essential per-server decisions interactive or online:

  • Admin password prompt: Prompts to set or skip the admin user's login password (unless supplied via --password-file or --config).
  • SSH key fallback prompt: Automatically uses keys from SUDO_USER or /root/.ssh/authorized_keys, and only prompts you to paste one if none is found.
  • Online IP timezone: Enables AUTO_TIMEZONE="true" (api.ipapi.is / ip-api.com) automatically with fallback to America/Los_Angeles.
  • Full stack enabled: NOPASSWD sudo, deploy user, key-only SSH, ufw + fail2ban, apt upgrade + tools, unattended-upgrades (04:00–05:30 Asia/Singapore), BBR fq_codel, 2G swap + auto zram, and 50M journald caps.
bash <(curl -fsSL 'https://vps-bootstrap.pages.dev/vps-setup.sh') --preset recommended
View .conf
Security: Presets strictly reject password keys (ADMIN_PASSWORD, DEPLOY_PASSWORD). Use a local --config file or --password-file for preset-free secrets.

Interactive Command Builder

Generate a tailored command with only the flags you need—defaults stay omitted.

bash <(curl -fsSL 'https://vps-bootstrap.pages.dev/vps-setup.sh')
Note: -fsSL / -fsSLO keeps redirect handling (-L) and strict HTTP failure checks (-f). If not running as root, pick curl -fsSLO + sudo or download first with curl -fsSLO before running sudo bash vps-setup.sh.

RAM-Tiered TCP Buffer Profiles

Automatically selected from /proc/meminfo and written to 99-zzz-network-tuning.conf.

Detected RAM Tier rmem_max wmem_max nf_conntrack_max
≤ 384 MiB256M4 MiB4 MiB32,768
≤ 768 MiB512M16 MiB8 MiB65,536
≤ 1536 MiB1G32 MiB16 MiB65,536
> 1536 MiB2G+64 MiB32 MiB131,072

Project Files & Endpoints

Served directly from Cloudflare Pages and mirrored on GitHub.

Copied!