Your own server
From an empty VPS to a server that installs its own updates, bans brute force, reports failures, keeps backups off the server, and moves to a new VPS from git and a backup. One server for the whole path: each level starts where the previous one ended.
Levels
Base
You stopped hereKey-only login, a firewall, updates that install themselves, limits on memory and the journal, Docker ready for services.
RecipeNew server: the first hourTips for this level- Provider console
- Keep the old session open
- Is a reboot needed
- An SSH key on a token:
ed25519-sk - Ubuntu Pro is free for personal machines
- Overview · A new Ubuntu server: what to set up in the first hour and why
- Recipe · New server: the first hour
- Manual · First login to a server: updates, hostname, a sudo user, key login
- Manual · SSH keys: from ssh-keygen to passwordless login
- Config · sshd_config: key-only login, no root, no passwords
- Manual · The ufw firewall: everything closed except SSH and web
- Config · unattended-upgrades: security updates on their own and a reboot at 4:00
- Manual · Swap, journal and time: three settings for a small VPS
- Manual · Docker on Ubuntu: from Docker’s repository, with a log limit
- Config · cloud-init: a server configured the moment it’s created
- Cheat sheet · An Ubuntu server: everyday commands
- Tip · The provider console is your fallback — test it before making changes
- Tip · Editing sshd or the firewall? Keep the old session open
- Tip · After an update, check /var/run/reboot-required
Protection
You stopped hereBrute force is banned server-wide, no stray ports are visible from outside.
RecipeProtection: brute-force bans and closed portsTips for this level- Docker ports bypass the input chain
- Test your server’s protection by action
- Port 22
systemd-analyze securityscores a service- SSH certificates: access that expires
- Recipe · Protection: brute-force bans and closed ports
- Manual · CrowdSec against SSH brute force: a ban across the whole server
- Manual · SSH tunnels: a closed admin panel through localhost
- Cheat sheet · cscli and bouncers: everyday commands
- Tip · Docker ports bypass the input chain
- Tip · Test your server’s protection by action
- Tip · Moving off port 22 cuts log noise but doesn’t protect you
Services
You stopped hereApps in containers, by name and over HTTPS; only Traefik is open to the outside.
RecipeA service over HTTPS: Traefik and the first serviceTips for this level- docker.sock
- Single-file mounts
- traefik.yml doesn’t substitute variables
- A host-only port goes on 127.0.0.1
- Healthchecks and
up --wait - Pin the image by digest, not by tag
- Overview · Traefik: what it is and when to pick it
- Recipe · A service over HTTPS: Traefik and the first service
- Manual · Traefik from scratch: the first service by name, with HTTPS
- Cheat sheet · Traefik labels: router, middleware, service
- Config · traefik.yml block by block: what each setting means
- Manual · Traefik and Let’s Encrypt: wildcard, ACME, a certificate for neighbours
- Manual · Secrets in Docker stacks: where to keep them and how not to leak them
- Manual · CrowdSec with Traefik behind Cloudflare: two bouncers and X-Forwarded-For
- Tip · docker.sock only for those that can’t do without it
- Tip · A single-file mount doesn’t see your edits
- Tip · traefik.yml doesn’t substitute variables
- Tip · A host-only port goes on 127.0.0.1
Observability
You stopped hereYou can see what’s going on, and the server reports when something is wrong.
RecipeMetrics, uptime checks and alertsTips for this level- An alert when a job didn’t run
OnFailure=for systemd services- A WAF with CrowdSec AppSec
Backups
You stopped hereData survives the server being deleted.
RecipeA backup that outlives the serverTips for this levelMigration
You stopped hereThe whole server or some of its stacks come up on a new VPS from git and a backup — after a failure, when changing hosts, or when the server can’t keep up.
RecipeMoving to a new serverTips for this level- TTL записей DNS снижаем за сутки до переезда
- A leaked sops key:
rotateand new secrets
Automation
You stopped hereUpdates and deploys run on their own, without logging in over SSH.
RecipeDeploy without SSHTips for this level- CI builds the image, the server pulls it from a registry
- Renovate watches image versions
- systemd timers instead of cron
- A script that git replaces mid-run
- Why not SSH from GitHub Actions
Dashed means not written yet: the map shows everything a server of your own can have, not just what’s done. A white tip exists, a dashed one is coming.
Already have a server: where to pick up
The “Done when” checks from the recipes. Run them on your server and mark what passes — the level to continue from shows up below. Marks stay in this browser only.
sudo sshd -T | grep -E '^(permitrootlogin|passwordauthentication) '→ permitrootlogin no and passwordauthentication nosudo ufw status | head -1→ Status: activeapt-config dump | grep -E 'Automatic-Reboot(-Time)? '→ Automatic-Reboot "true" and Automatic-Reboot-Time "04:00"swapon --show→ /swapfile file 2Gsudo docker run --rm hello-world | grep Hello→ Hello from Docker!sudo docker exec crowdsec cscli bouncers list→ firewall-bouncer, with Last API pull seconds agosudo nft list table ip crowdsec | grep hook→ two lines: hook input and hook forwardsudo docker exec crowdsec cscli metrics show acquisition→ a file:/var/log/auth.log line with non-zero numberssudo ss -tlnH | awk '{print $4}' | grep -v -e '^127\.' -e '^\[::1\]'→ only :22; after level 3, :80 and :443 as wellsudo docker ps --filter name=traefik --format '{{.Names}} {{.Status}}'→ traefik Up …curl -sI http://whoami.example.org | head -1→ HTTP/1.1 308 Permanent Redirectecho | openssl s_client -connect whoami.example.org:443 -servername whoami.example.org 2>/dev/null | openssl x509 -noout -issuer→ issuer says Let's Encryptcurl -m 5 -s http://203.0.113.10:5230 || echo closed→ closed: memos is reachable only by namesudo docker ps --format '{{.Names}} {{.Status}}' | grep -E '^(beszel|beszel-agent|gatus) '→ three lines, each Up …curl -s -o /dev/null -d 'Test from web1' ntfy.sh/$(sudo cat /srv/secrets/ntfy/topic)→ “Test from web1” on your phonecd /opt/memos && sudo docker compose stop→ a Gatus alert about memos within 3–4 minutes; after sudo docker compose start, a note that it answers againsudo ss -tlnH | awk '{print $4}' | grep -v -e '^127\.' -e '^\[::1\]'→ still only :22, :80 and :443: monitoring opened nothing to the outsidesystemctl list-timers 'kopia-*'→ two timers, kopia-backup.timer and kopia-verify.timer, both with NEXT filled insudo kopia snapshot list --all→ root@web1:/opt and root@web1:/srv/secrets, each with snapshots from the last nightssudo systemctl start kopia-verify.service→ returns without an error after a few minutes, the web1-verify check in Healthchecks.io is upHealthchecks.io, the `web1-backup` check→ up, last ping today around 03:00sudo git -C /opt status --short→ nothing: everything that belongs in git is committedsudo git -C /opt ls-files host scripts→ host/bootstrap.sh, host/authorized_keys, files under host/etc/ and scripts/restore.shcurl -s -o /dev/null -w '%{http_code}\n' --resolve memos.example.org:443:203.0.113.20 https://memos.example.org→ 200 from a server brought up from git and the backup: in a drill, from the temporary VPSsystemctl list-timers deploy.timer→ one timer, with NEXT no more than 10 minutes awaycurl -s https://whoami.example.org | grep Name→ Name: from-git: a change from your computer reached the server without an SSH loginsudo grep -h 'image:' /opt/*/docker-compose.yaml→ every image has @sha256:…: Renovate manages the versionsServer profile
Every recipe on the path follows these rules, so the levels fit together: the backup knows where the data and certificates are, monitoring knows which services to check, and git on the Migration level picks up the same paths.
| What | Where and how |
|---|---|
| Stack | /opt/<stack>/docker-compose.yaml — a directory of its own for every service |
| Name | one for everything: directory /opt/memos, container memos, Traefik router memos, address memos.example.org |
| Data | /opt/<stack>/data/, in compose — ./data:… |
| Secrets | as a file in /srv/secrets/<stack>/ (a Docker secret) or in /opt/<stack>/.env with mode 600; git gets only .env.example with the names |
| Network | proxy, external: create it once; Traefik and every service it exposes join it |
| Open ports | only 22, 80 and 443; services have no ports:, they’re reached by name through Traefik |
| User | example-user with sudo, key login; root can’t log in over SSH; recipe commands run with sudo |
| Request log | /opt/traefik/data/logs/access.log, JSON |
| Scripts | for the whole server — /opt/scripts/, for one stack — in its directory |
| Your values | email [email protected], domain example.org, server address 203.0.113.10, user example-user, server name web1, backup server address 198.51.100.20You can enter your own |