scripts that turn a fresh vps into a box i don't have to think about again.
every provider hands you a root shell, a password in an email and a vague feeling that you forgot something. this repo is the thing i kept forgetting.
one entrypoint per distro. debian 13 is the one that matters, the rest is a directory layout waiting to happen.
debian13-postinstall.shapplies my defaults to a fresh debian 13 box.audit/debian13-audit.shreads the box back and tells me what drifted.config/postinstall.envholds the opinions (user, port, tokens, modules).docs/holds the "why", per topic, so future me stops guessing.
it is idempotent. run it once after the provider mail, run it again next month after adding a module. it skips what already matches, backs up what it rewrites.
Warning
this disables root ssh and password auth. if there is no key for the new user you will lose the box. the script refuses to continue when it detects that, but read docs/hardening/ssh.md before you find out the hard way.
git clone https://github.com/extencil/postinstall
cd postinstall
install -m 0600 config/postinstall.env.example config/postinstall.env
$EDITOR config/postinstall.env # user, port, timezone, modules
sudo bash debian13-postinstall.sh --dry-run
sudo bash debian13-postinstall.shend to end on a fresh box, no menu, no prompts. the only thing that can ask you anything is apt.
then prove you can log in as the new user on the new port before you close the root shell. use the provider console if you enjoy not being locked out.
the postinstall generates a fresh 64-character password on the host and stores
it root-only at /root/postinstall-<user>.password. read it from the open root
session or the provider console, then change it with passwd if you want a
different one. SSH stays public-key only; the password is only for local
privilege elevation. reruns do not rotate an existing password.
NEW_USER_PASSWORD and NEW_USER_PASSWORD_FILE exist for an explicit opt-in.
leave both empty unless you really need a pre-set value.
order is not decoration. the firewall opens SSH_PORT before sshd moves to it,
and fail2ban starts after the ruleset exists. real ssh defaults to 1/tcp;
use ssh -p 1 ops@example.com for a fresh deployment. the decoy takes 22/tcp
after real ssh moves. existing configs keep their explicit SSH_PORT; change
22 before upgrading with the decoy enabled.
flowchart LR
preflight --> users --> firewall --> ssh --> ssh_prank --> fail2ban --> sysctl
sysctl --> updates --> tools --> shell --> docker --> python
python --> cloudflare --> dotfiles --> audit
node, go and dotfiles are off by default. cloudflared too, until you put
a token in the config.
| module | what it actually does |
|---|---|
preflight |
debian check, apt index, timezone, timesyncd, hostname |
users |
creates NEW_USER, sudo password, ssh key, locks root, disables debian |
firewall |
nftables, input drop, only ssh + your extra ports |
ssh |
key only, no root, real ssh on tcp/1, socket aware |
ssh_prank |
reject-only decoy on tcp/22, bounded connections, separate service |
fail2ban |
sshd jail reading the journal, bans in nftables |
sysctl |
kernel and network knobs, the safe ones |
updates |
unattended security upgrades, no surprise reboots |
tools |
git, tmux, ripgrep, fd, bat, btop, mtr, the usual bag |
shell |
zsh as login shell, dotfiles do the rc files |
docker |
upstream repo, log rotation, no-new-privileges |
python |
venv, pipx, uv |
node |
nodesource apt repo, pinned major (optional) |
go |
distro golang (optional) |
cloudflared |
dashboard tunnel, official apt repo, systemd host service (optional) |
dotfiles |
clones the repo that makes the box mine (optional) |
verify |
runs the audit at the end, never fails the run |
flags:
sudo bash debian13-postinstall.sh --dry-run
sudo bash debian13-postinstall.sh --only firewall,ssh,ssh_prank,fail2ban
sudo bash debian13-postinstall.sh --skip docker,node,go
sudo bash debian13-postinstall.sh --only preflight,users,firewall,ssh --keep-default-users --keep-root-password
sudo bash debian13-postinstall.sh --user ops --port 2222 --timezone Europe/Amsterdam
sudo bash debian13-postinstall.sh --list
sudo bash debian13-postinstall.sh --auditconfig/postinstall.env.example is the whole surface. it is a shell file, so
anything you can write in bash works, including $(cat token). two things to
know:
- it holds tunnel tokens. keep it out of git, keep it
0600, and prefer token files over inlining the token. - precedence is flags > config file > environment > defaults.
the parts people touch:
NEW_USER=ops
NEW_USER_PASSWORD="" # leave empty to generate on the host
NEW_USER_PASSWORD_FILE="" # optional 0400/0600 file; empty = generate
DISABLE_DEFAULT_USERS=debian # lock, expire, nologin, deny ssh
SSH_PORT=1
TIMEZONE=UTC
SSH_PUBKEY_FILE=/root/.ssh/authorized_keys
CLOUDFLARED_TOKEN_FILE=/root/.secrets/cf-tunnel.token
ENABLE_DOCKER=1
ENABLE_CLOUDFLARED=1every knob and its default
| key | default | what |
|---|---|---|
NEW_USER |
ops |
the human account |
NEW_USER_PASSWORD |
empty | optional inline bootstrap password; leave empty to generate |
NEW_USER_PASSWORD_FILE |
empty | optional chosen password file, 0400/0600; empty generates root-only |
DISABLE_DEFAULT_USERS |
debian |
provider accounts to lock, expire, nologin and deny over ssh |
LOCK_ROOT_PASSWORD |
1 |
lock root after sudo works; 0 only for a staged POC |
SSH_PORT |
1 |
real ssh port, firewall follows; decoy uses 22 |
SSH_PRANK_BANNER_FILE |
empty | optional public UTF-8 banner for the decoy |
HOSTNAME_SET |
empty | leave the provider hostname alone |
TIMEZONE |
UTC |
iana name |
APT_LOCK_TIMEOUT |
300 |
seconds to wait for unattended-upgrades to release dpkg |
SSH_PUBKEY_FILE |
empty | key file, relative paths resolve against the repo; falls back to /root/.ssh/authorized_keys |
SSH_PUBKEY |
empty | inline public key, wins over the file |
SSH_ALLOW_USERS |
empty | empty means only NEW_USER; disabled accounts are filtered out |
SSH_ALLOW_PASSWORD |
0 |
set 1 only if you enjoy passwords |
SSH_ALLOW_TCP_FORWARDING |
1 |
keep -L/-R working |
EXTRA_TCP_PORTS |
empty | inbound tcp, space or comma separated |
EXTRA_UDP_PORTS |
empty | inbound udp |
SUDO_NOPASSWD |
0 |
0 asks for the local password; never affects SSH auth |
DOCKER_ADD_USER_TO_GROUP |
1 |
root-equivalent, read the docker doc |
PYTHON_INSTALL_UV |
1 |
uv into /usr/local/bin |
NODE_MAJOR |
24 |
nodesource major |
CLOUDFLARED_TOKEN_FILE |
empty | tunnel token file, 0400/0600 |
CLOUDFLARED_TOKEN |
empty | inline fallback, visible in ps; avoid |
DOTFILES_REPO |
empty | git url, cloned as NEW_USER |
DOTFILES_DIR |
empty | defaults to ~/.dotfiles |
DOTFILES_INSTALL_CMD |
empty | run inside the clone, as the user |
DOTFILES_UPDATE |
1 |
git pull --ff-only on reruns |
ENABLE_* |
per module | 0 skips it, --only/--skip override |
read only, prints ok / warn / FAIL per check, exit 1 if anything failed.
that makes it usable from cron or a pre-change gate.
sudo bash audit/debian13-audit.sh
sudo bash audit/debian13-audit.sh --quiet
sudo bash audit/debian13-audit.sh --config config/postinstall.env== ssh
ok sshd permitrootlogin no
ok sshd passwordauthentication no
ok drop-in /etc/ssh/sshd_config.d/00-postinstall.conf present
ok something listens on tcp/1
== firewall
ok table inet filter present
ok input policy drop
ok tcp/1 allowed in
== score
31 ok 2 warn 0 fail 3 skip
it checks ssh effective config (not just the file), the live nftables ruleset, jail status, every sysctl it deployed, timers, packages, docker daemon keys, cloudflare units, world-facing listeners and the pending-reboot flag.
details and exit codes: docs/audit.md.
audit-fleet.sh runs the same read-only audit on every host in
debian-hosts-pool.txt. each host gets an ssh -t, so remote sudo can ask for
the password on your terminal.
cp debian-hosts-pool.txt.example debian-hosts-pool.txt
chmod 600 debian-hosts-pool.txt
$EDITOR debian-hosts-pool.txt
./audit-fleet.sh
./audit-fleet.sh 2>&1 | tee fleet-audit.logthe host list and captured output are gitignored. never commit real addresses.
.
├── debian13-postinstall.sh # entrypoint, flags, module runner
├── AGENTS.md # canonical llm/harness contract
├── config/
│ └── postinstall.env.example # copy to postinstall.env, gitignored
├── assets/shell/zsh/.zshrc # optional interactive profile
├── lib/
│ ├── common.sh # logging, run(), write_file(), backups
│ └── modules/ # one file per topic, numbered by order
├── audit/
│ └── debian13-audit.sh # read-only report card
└── docs/
├── debian-13.md # trixie specific gotchas
├── hardening/ # ssh, firewall, fail2ban, sysctl, updates
├── network/cloudflare.md # dashboard tunnel, host service
├── runtimes/ # docker, python, node, go
├── shell/ # tooling and the daily zsh profile
├── secrets/dotfiles.md
└── checklists/new-vps.md # the boring paper checklist
AGENTS.md is the canonical instruction file for llms and harnesses.
CLAUDE.md, GEMINI.md, .github/copilot-instructions.md,
.cursor/rules/postinstall.mdc and llms.txt are thin pointers so every tool
lands in the same place instead of inventing its own rules.
| doc | read it when |
|---|---|
| debian 13 notes | the box is trixie and something behaves oddly |
| ssh | port changed, socket activation, lockout recovery |
| ssh prank | port 22 decoy, limits, deployment and recovery |
| firewall | adding a port, docker + nftables, debugging drops |
| fail2ban | checking or lifting a ban |
| sysctl | wondering what a knob does and why it is not here |
| updates | controlling the 6am upgrade window |
| cloudflare | dashboard tunnel, apt repo, host service, zero inbound |
| docker | daemon.json choices and the group warning |
| python | uv, pipx, venvs |
| node and go | version pins, why optional |
| tooling | package list and the bat/fd renames |
| daily Zsh profile | copy-and-paste Debian setup for a Kali-inspired interactive shell |
| dotfiles and secrets | age, sops, gpg, clone order |
| audit | wiring it into cron |
| first VPS verification | what the staged live run proved and what it did not |
| new vps checklist | provider day |
| agent notes | working on the repo with an llm |
- not a cis benchmark runner. no compliance checkbox, no scoring dashboard.
- not a monitoring stack. uptime checks live somewhere else.
- not protection from root. if someone is root, the box is theirs.
- not a backup system. a hardened box that loses its data is still a lost box.
- not distro agnostic. trixie-only, on purpose.
aptand systemd everywhere.
things left alone deliberately: ip_forward (docker), ipv6 accept_ra (some
providers hand v6 out over RA and disabling it drops the address), docker's
rootless userns settings, and anything that needs a reboot to prove itself.
pending work and verification checks live in TODO.md.
issues and prs are welcome. keep it boring: apt packages over curl installers, idempotent over clever, one module per topic, and update the audit when you add a module that changes state. use conventional commits with an imperative subject and explain migration steps and validation when relevant.
the shellcheck line:
shellcheck -x debian13-postinstall.sh lib/common.sh lib/modules/*.sh audit/*.shjoin haltman or go straight to the telegram group.
unlicense. it is a shell script, not a startup. see LICENSE.