Debian Setup
Personal Debian VPS dotfiles and setup scripts powered by apt, proto, and Oh My Zsh.
Prerequisites
The script requires either root or a user with sudo access. It will exit early with an error if neither is available.
| Prerequisite | Notes |
|---|---|
sudo or root | Required to install packages and write to system directories |
curl | Downloads the pinned releases (proto, Helm, k9s, GCM) and apt keys |
git | Installed automatically via apt in the common step |
Installation
Remote (fresh server)
# Full install — all profiles, dotfiles, completions
bash <(curl -fsSL https://raw.githubusercontent.com/KevinDeBenedetti/dotfiles/v0.20.0/os/debian/init.sh) -aThe script clones the latest release of the repository to ~/.dotfiles (or checks that release out in an existing clone), then re-executes from there. Set DOTFILES_REF to run another tag or branch (DOTFILES_REF=main).
Local
# Clone
git clone https://github.com/KevinDeBenedetti/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
# Full install
./os/debian/init.sh -a
# Dotfiles only
./os/debian/init.sh -d
# Specific profiles + completions
./os/debian/init.sh -p "base,kubernetes" -cFlags
| Flag | Description |
|---|---|
-a | Full install: all profiles + dotfiles + completions + cleanup |
-p <profiles> | Comma-separated list of profiles (e.g. base,kubernetes) |
-d | Link dotfiles into $HOME |
-c | Install zsh CLI completions |
-l | Lite mode — skip optional/heavy packages |
-u <user> | Create a non-root sudo user before the security profile hardens SSH |
-h | Print help |
At least one flag is required. Running without flags prints help and exits.
Common Packages
Installed unconditionally before any profile (via apt):
ca-certificates, curl, gnupg, gzip, jq, unzip, wget, xz-utils, git, build-essential
Oh My Zsh is also installed at this stage if ~/.oh-my-zsh does not exist: it is cloned at the commit pinned in os/helpers/oh-my-zsh.sh, with no installer script, and updates itself from master afterwards.
Profiles
base
Core CLI tools installed via apt. Split into lite (always) and additional (full mode only).
Lite:
| Tool | Description |
|---|---|
| Docker CE | Docker engine from the official upstream repository |
docker-ce, docker-ce-cli, containerd.io | Core engine, CLI client, and container runtime |
docker-buildx-plugin, docker-compose-plugin | BuildKit and Compose v2 plugins |
ansible | Agentless configuration management and provisioning |
fzf | Fuzzy finder for shell history, files, and more |
ssh | OpenSSH client |
tree | Directory tree visualizer |
watch | Repeat a command at intervals |
yq | Portable YAML/JSON/TOML processor |
rsync | Incremental file transfer |
| Terraform | Infrastructure as code, from HashiCorp's apt repository |
| Git Credential Manager | HTTPS Git credential helper behind credential.helper = manager |
proto | Toolchain version manager (pinned release, SHA-256 verified) |
Docker CE is installed from
https://download.docker.com/linux/debianusing the official GPG key. The calling user is automatically added to thedockergroup.
The apt keys of Docker, HashiCorp and Kubernetes (
pkgs.k8s.io) are trusted only when they match the fingerprint pinned in the script: a rotated or swapped key aborts the run before apt trusts it. When a vendor rotates its key, update the fingerprint from the vendor's announcement.On a node managed by the infra repository, the script leaves Docker out. It recognises such a node by the sshd drop-in that repository writes,
/etc/ssh/sshd_config.d/00-infra-hardening.conf, the same marker that makes it skip SSH hardening. Those nodes run k3s with its own containerd, and their Ansible removes Docker, whose iptables rules forward published ports around the host firewall.Git Credential Manager comes from the release pinned in
os/debian/setup-base.sh(.deb, amd64 or arm64), checked against the SHA-256 pinned next to it before apt installs it. A download that fails or does not match stops the profile, as for every pinned release (proto, Helm, k9s). A machine that already hasgit-credential-managerork9skeeps the build it has: bumping a pin does not upgrade it. Linux has no default credential store, so when none is configured the script setscredential.credentialStore cachein the system config (/etc/gitconfig): credentials stay in memory (15 minutes by default), never on disk.
Additional (full mode):
| Tool | Description |
|---|---|
gh | GitHub CLI — PRs, issues, repos from the terminal |
nmap | Network exploration and port scanning |
security
Hardens the system using a layered approach. Activated with -p security or included in -a (full install).
Environment variables
Set these before invoking the script to customize security behaviour:
| Variable | Default | Description |
|---|---|---|
SSH_PORT | 22 | TCP port sshd listens on |
SSH_ALLOWED_USERS | (all) | Space-separated list of users permitted to log in via SSH |
SSH_NOPASSWD | false | Give the user created by -u passwordless sudo |
COPY_ROOT_SSH_KEY | true | Add root's authorized_keys to the user created by -u, keeping its own |
HARDEN_TMP | false | Remount /tmp as a noexec tmpfs capped at 1G (opt-in) |
HARDEN_IPV6_RA | false | Ignore IPv6 router advertisements (opt-in) |
# Example: custom port + restrict SSH to a single user
SSH_PORT=2222 SSH_ALLOWED_USERS="deploy" bash <(curl -fsSL ...) -aSSH hardening (/etc/ssh/sshd_config.d/00-hardening.conf)
| Setting | Value | Effect |
|---|---|---|
Port | $SSH_PORT | Configurable port (default: 22) |
PermitRootLogin | no | Disable direct root login (see below) |
PasswordAuthentication | no | Key-only authentication |
MaxAuthTries | 3 | Block brute-force attempts |
X11Forwarding | no | No X11 tunnelling |
AllowTcpForwarding | no | No arbitrary port forwarding |
ClientAliveInterval | 300 | Disconnect after 5 min idle |
AllowUsers | $SSH_ALLOWED_USERS | Restrict login to named users (optional) |
sshd keeps the first value it reads and loads drop-ins in lexical order, so the file is named 00- to win over others such as cloud-init's 50-cloud-init.conf. After writing it, the script checks the effective configuration (sshd -T) and warns if PermitRootLogin or PasswordAuthentication is still overridden.
Two safeguards keep the hardening from locking you out:
- Root login stays on (key only) until another admin can log in. Root login is turned off only when a non-root member of the
sudogroup has a non-empty~/.ssh/authorized_keys, can runsudo(a password set, or aNOPASSWDrule) and is listed inSSH_ALLOWED_USERSwhen that is set. Otherwise the script writesPermitRootLogin prohibit-passwordand warns; whenSSH_ALLOWED_USERSis set,rootis added toAllowUsersfor as long as that lasts, sinceAllowUsersrefuses every user it does not name. Create the user with-u <user>(withSSH_NOPASSWD=true, or set its password withsudo passwd <user>), then re-run the security profile. - A drop-in that breaks sshd is moved aside. If
sshd -tpassed before the drop-in was written and fails after, the file is renamed to00-hardening.conf.rejected, sshd is not restarted and the run stops (UFW is not reconfigured for a port sshd does not listen on).
UFW firewall
Default policy: deny all incoming, allow all outgoing. Rules added:
| Rule | Protocol | Comment |
|---|---|---|
$SSH_PORT/tcp | TCP | SSH (respects custom port) |
80/tcp | TCP | HTTP |
443/tcp | TCP | HTTPS |
UFW is reset only on its first run, while it is inactive: re-running the security profile adds these rules again and keeps those you added since.
The firewall is configured before sshd is hardened, so a re-run with another SSH_PORT opens the new port before sshd restarts on it. Once sshd has restarted, the rule of the previous port is removed; when the restart fails, that port stays open and a warning gives the command that closes it.
WARNING
Docker writes its own iptables rules ahead of UFW's, so UFW does not filter ports published by containers. When Docker is installed, the script sets "ip": "127.0.0.1" in /etc/docker/daemon.json: -p 5432:5432 then binds to loopback only. Publish a service on purpose with an explicit address (-p 0.0.0.0:443:443).
Fail2Ban (/etc/fail2ban/jail.local)
| Setting | Value |
|---|---|
bantime | 1 hour |
findtime | 10 minutes |
maxretry | 3 attempts |
backend | systemd |
banaction | ufw |
python3-systemd is installed with it: the systemd backend needs it, and it is only a Recommends of the fail2ban package.
On a node managed by the infra repository (same marker as for Docker,
/etc/ssh/sshd_config.d/00-infra-hardening.conf), the script skips SSH hardening, UFW and Fail2Ban: sshd and the firewall belong to that repository's Ansible, and a jail whose ban action is UFW could not ban anyone where UFW is not installed. The other hardening steps still run.
Sysctl hardening (/etc/sysctl.d/99-security.conf)
Network:
| Parameter | Value | Effect |
|---|---|---|
net.ipv4.tcp_syncookies | 1 | SYN flood protection |
net.ipv4.tcp_rfc1337 | 1 | TIME_WAIT assassination protection |
net.ipv4.ip_forward | 0 | No IP forwarding |
net.ipv4.conf.all.accept_redirects | 0 | Ignore ICMP redirects (MITM) |
net.ipv4.conf.all.rp_filter | 1 | Reverse path filtering (anti-spoof) |
Kernel:
| Parameter | Value | Effect |
|---|---|---|
kernel.kptr_restrict | 2 | Hide kernel pointer addresses in /proc |
kernel.dmesg_restrict | 1 | Restrict kernel log access to root |
kernel.randomize_va_space | 2 | Full ASLR enabled |
kernel.yama.ptrace_scope | 1 | Restrict ptrace to parent processes |
net.core.bpf_jit_harden | 2 | Harden BPF JIT compiler |
vm.mmap_min_addr | 65536 | Prevent null pointer dereference exploits |
Filesystem:
| Parameter | Value | Effect |
|---|---|---|
fs.suid_dumpable | 0 | No core dumps for setuid binaries |
fs.protected_symlinks | 1 | Protect symlinks in world-writable sticky dirs |
fs.protected_hardlinks | 1 | Only owner can follow hardlinks |
fs.protected_fifos | 2 | Restrict FIFO creation in sticky directories |
fs.protected_regular | 2 | Restrict regular file creation in sticky directories |
Shared memory & /tmp (/etc/fstab)
| Mount point | Options |
|---|---|
/dev/shm | noexec,nosuid,nodev |
/tmp | noexec,nosuid,nodev,size=1G |
The /tmp entry is only added with HARDEN_TMP=true: noexec on /tmp breaks some apt/dpkg maintainer scripts and builds, and the 1G cap is wrong for small servers.
AppArmor
Installs apparmor and apparmor-utils and enables the service. The GRUB boot parameters (apparmor=1 security=apparmor) are added only where the kernel does not run AppArmor already, which Debian does by default since version 10. Each profile keeps the mode its package ships it in: forcing every profile to enforce breaks the services whose profile is in complain mode on purpose.
CrowdSec (full mode only)
Collaborative threat-intelligence IPS. Adds CrowdSec's packagecloud apt repository directly (no remote install script runs as root): the repository key must match the fingerprint pinned in setup-security.sh, otherwise the run aborts before apt trusts it. Then installs crowdsec and adds:
crowdsec-firewall-bouncer-iptables— automatic firewall banning- Collections:
crowdsecurity/linux,crowdsecurity/sshd
Unattended upgrades
Configures automatic security patches only, in /etc/apt/apt.conf.d/52dotfiles-unattended-upgrades: it clears the origins of the packaged 50unattended-upgrades (left untouched, it is a dpkg conffile) and allows only the security archive (label=Debian-Security, or Ubuntu's <codename>-security). Auto-reboot is disabled.
Check which upgrades it would apply with sudo unattended-upgrade --dry-run -d.
Security audit tools (full mode only)
| Tool | Description |
|---|---|
lynis | System and security auditing |
rkhunter | Rootkit scanner |
chkrootkit | Another rootkit checker |
auditd | Kernel audit framework |
kubernetes
Tools for Kubernetes cluster management.
Lite:
| Tool | Description |
|---|---|
kubectl | Kubernetes command-line client, from the official pkgs.k8s.io repo of one pinned minor (install_kubectl in os/debian/setup-kubernetes.sh), moved to each new minor by Renovate; a re-run moves a kubectl from an older minor's repo |
On a node managed by the infra repository (same marker as for Docker,
/etc/ssh/sshd_config.d/00-infra-hardening.conf), the script installs neitherkubectlnor thepkgs.k8s.iorepository: k3s ships its ownkubectl, and that repository's Ansible removes both on every run.
Additional (full mode):
| Tool | Description |
|---|---|
helm | Kubernetes package manager (pinned release, SHA-256 verified; amd64/arm64) |
k9s | Terminal UI for Kubernetes clusters (pinned release, SHA-256 verified) |
Dotfiles Linking
Running -d symlinks (or copies) config files from the repository into $HOME. Any existing file is backed up with a datestamp (e.g. ~/.zshrc.bak.20260311) before being replaced.
| Source | Target | Method |
|---|---|---|
config/zsh/.zshrc | ~/.zshrc | copy¹ |
config/git/.gitconfig | ~/.gitconfig | symlink |
config/git/ignore | ~/.config/git/ignore | symlink |
config/proto/.prototools | ~/.proto/.prototools | symlink |
config/oh-my-zsh/*.zsh-theme | ~/.oh-my-zsh/custom/themes/ | symlink |
config/shell/* | ~/.config/dotfiles/ | symlink |
config/ssh/config | ~/.ssh/config | symlink |
config/claude/settings.json | ~/.claude/settings.json | symlink |
config/claude/hooks/* | ~/.claude/hooks/ | symlink |
config/skills/*/ | ~/.claude/skills/ | symlink |
config/skills/*/ | ~/.copilot/skills/ | symlink |
config/skills/*/SKILL.md | ~/.config/opencode/commands/*.md | symlink³ |
config/agents/AGENTS.md | ~/.claude/AGENTS.md | symlink |
config/claude/CLAUDE.md | ~/.claude/CLAUDE.md | symlink |
config/agents/AGENTS.md | ~/.config/opencode/AGENTS.md | symlink |
config/agents/AGENTS.md | ~/.copilot/copilot-instructions.md | symlink |
config/opencode/opencode.json | ~/.config/opencode/opencode.json | symlink |
config/copilot/hooks/* | ~/.copilot/hooks/ | symlink |
config/ai-tools/ | ~/.config/ai-tools | symlink |
scripts/*/* (executables) | ~/.local/bin/ | symlink |
config/ollama/ | ~/.config/ollama | symlink |
config/vscode/settings.json | ~/.config/Code/User/settings.json | symlink² |
config/vscode/mcp.json | ~/.config/Code/User/mcp.json | symlink² |
¹
.zshrcis copied rather than symlinked so machine-specific patches can be applied without affecting the tracked file.² Only when VS Code is installed:
settings.jsonandmcp.jsonneed thecodeCLI onPATH.³ Only for a user-invoked skill (a slash command): see Agent Skills.
Local override stubs
The -d step also creates the following stub files if they do not already exist. They are never tracked by git and always take precedence:
| File | Purpose |
|---|---|
~/.zshrc.local | Machine-specific zsh aliases, exports, and path additions |
~/.gitconfig.local | Machine-specific git overrides (e.g. user.email, signingkey) |
~/.config/dotfiles/env.local.sh | Machine-specific environment variable overrides (no API keys) |
SSH allowed signers
The script adds the signing key (user.signingkey, else the first ~/.ssh/id_*.pub, ed25519 first) to ~/.ssh/allowed_signers for local SSH commit signature verification, keeping any other signer in the file.
Completions
Running -c installs zsh completions for:
| Tool | Source |
|---|---|
gh | gh completion -s zsh |
proto | proto completions --shell zsh |
uv | uv generate-shell-completion zsh |
zsh-completions | Cloned at a pinned commit into Oh My Zsh custom plugins, added to fpath (a ~/.zshrc linked by scripts/symlink.sh is left alone: enable the line in config/zsh/.zshrc) |
Completions are written to /usr/local/share/zsh/site-functions (with sudo when not root).
Zsh Configuration
The .zshrc at config/zsh/.zshrc is copied to ~/.zshrc so machine-specific patches can be applied without affecting the tracked file.
History
| Setting | Value | Effect |
|---|---|---|
HISTSIZE | 10000 | Number of commands kept in memory per session |
SAVEHIST | 10000 | Number of commands persisted to ~/.zsh_history |
HIST_STAMPS | yyyy-mm-dd | Date prefix on every history entry |
HISTFILE | ~/.zsh_history | Persistent history file location |
Theme
A custom Oh My Zsh theme kevin-de-benedetti is linked from config/oh-my-zsh/ into ~/.oh-my-zsh/custom/themes/ and set via ZSH_THEME.
Plugins
The following Oh My Zsh plugins are enabled in .zshrc:
| Plugin | What it provides |
|---|---|
aliases | als command — lists all active aliases with descriptions |
colored-man-pages | ANSI colour for man pages — much easier to read |
direnv | Loads .envrc files if direnv is installed (not by these scripts on Debian) |
docker | Docker CLI completion and aliases (dbl, dcin, dps, etc.) |
docker-compose | docker compose completion and shorthand aliases (dcup, dcdown, etc.) |
gh | GitHub CLI (gh) shell completion |
git | Extensive Git aliases (gst, gco, glog, gcmsg, etc.) and branch in prompt |
gitignore | gi <lang> — fetches a .gitignore template from gitignore.io |
rsync | Aliases for common rsync patterns (rsync-copy, rsync-move, etc.) |
sudo | Double-press ESC to prepend sudo to the current or previous command |
fzf Integration
fzf is installed by the base profile. The tracked .zshrc adds the fzf Oh My Zsh plugin whenever fzf is on PATH, which turns on its completion and these key bindings:
| Binding | Action |
|---|---|
CTRL-T | Fuzzy-search files/directories and paste the path |
CTRL-R | Fuzzy-search command history and run selected entry |
ALT-C | Fuzzy cd into a subdirectory |
Local Overrides
The following files are sourced at the end of .zshrc if they exist. They are never tracked by git:
| File | Purpose |
|---|---|
~/.config/dotfiles/env.local.sh | Machine-specific environment variables (no API keys) |
~/.zshrc.local | Machine-specific aliases, path additions, and exports |
Shell Functions
Custom functions live in config/shell/functions.sh and are sourced automatically by .zshrc. Run lsfn to list all functions with their help text.
| Function | Usage | Description |
|---|---|---|
b64d | b64d <string> | Decode a base64 string |
b64e | b64e <string> | Encode a string to base64 |
browser | browser [-- <url>] | Start a Browsh terminal browser via Docker |
cheat_glow | cheat_glow <sheet> | Render a cheat cheatsheet through glow at 150 columns for readability |
check_cert | check_cert <url> | Print TLS certificate details for a domain using curl |
dks | dks <secret> [namespace] | Decode a Kubernetes secret — outputs all .data values base64-decoded via yq |
kbp | kbp <port> | Kill the process currently listening on the given TCP port |
randompass | randompass [length] | Generate a secure random password (default 24 chars) with mixed complexity |
timestampd | timestampd <unix_ts> | Convert a Unix timestamp to a human-readable date (cross-platform) |
timestampe | timestampe <YYYY-mm-ddTHH:MM:ss> | Convert a date string to its Unix timestamp (cross-platform) |
vpn | vpn <up|down|status|list> [tunnel] | Manage WireGuard tunnels via wg-quick (aliases: vup, vdown, vpns) |
Run any function with
-hor--helpto see its usage message, e.g.dks -h.
Git Configuration
config/git/.gitconfig is symlinked to ~/.gitconfig. Key settings:
| Section | Setting | Value | Effect |
|---|---|---|---|
user | useConfigOnly | true | Identity must come from a config file, never guessed |
push | default | simple | Push to the tracking branch only (safe default) |
pull | rebase | true | Always rebase on pull instead of merge |
branch | autosetuprebase | always | New branches track their remote with rebase |
rerere | enabled | true | Record and replay conflict resolutions automatically |
commit | gpgsign | true | Sign every commit with your SSH key |
tag | gpgSign | true | Sign every tag with your SSH key |
gpg | format | ssh | Use SSH key (not GPG keyring) for signing |
gpg.ssh | allowedSignersFile | ~/.ssh/allowed_signers | File that maps emails to trusted public keys |
init | defaultBranch | main | New repositories default to main |
credential | helper | manager | HTTPS auth through Git Credential Manager³ |
url | insteadOf | git@github.com: | GitHub SSH remotes are rewritten to HTTPS (GCM) |
³ Git Credential Manager is installed by the
baseprofile; without it, git warns thatcredential-manageris not a git command and falls back to prompting. Details in Git.
Machine-specific overrides
Create ~/.gitconfig.local — it is [include]d at the bottom of .gitconfig and is never tracked by git:
# ~/.gitconfig.local
[user]
email = server@yourdomain.com
signingkey = ~/.ssh/id_ed25519_server.pubSSH commit signing
The dotfiles install adds the signing key to ~/.ssh/allowed_signers: the key in user.signingkey, else the first of ~/.ssh/id_ed25519.pub, id_ecdsa.pub and id_rsa.pub. It updates that key's line only, keeping any other signer in the file. This allows Git to verify signed commits locally with git log --show-signature.
SSH Client Configuration
config/ssh/config is symlinked to ~/.ssh/config. The global Host * block applies to every connection:
| Directive | Value | Effect |
|---|---|---|
SendEnv -LC_* -LANG | (off) | Do not forward locale variables — avoids setlocale warnings on servers |
ControlMaster | auto | Reuse an existing connection if one is already open |
ControlPath | ~/.ssh/cm-… | Socket path for multiplexed connections |
ControlPersist | 60s | Keep the master connection open for 60 s after the last session closes |
ServerAliveInterval | 60 | Send a keepalive packet every 60 s |
ServerAliveCountMax | 3 | Drop the connection after 3 missed keepalives (~3 min) |
proto Toolchain
config/proto/.prototools is symlinked to ~/.proto/.prototools. It pins global tool versions and configures proto's behaviour:
# bun, node, pnpm, yarn, python and go: one exact version each
# (see the file for the numbers)
npm = "bundled" # ships with the Node.js version
[tools.node]
bundled-npm = true # keep npm in sync with node
[tools.npm]
shared-globals-dir = true # global npm packages in a single shared dir
[settings]
auto-install = true # install missing tool versions automatically
auto-clean = true # remove unused tool versions after upgrades
pin-latest = "global" # record the resolved "latest" version globallyManaging tool versions
# Install a specific version
proto install node 22
# Install a version and pin it in the current directory only (./.prototools)
proto install python 3.12 --pin local
# List the configured tools and whether each is installed
proto status
# Upgrade proto itself
proto upgradeUseful apt Commands
# Refresh package index
sudo apt-get update
# Upgrade all installed packages
sudo apt-get upgrade
# Install a package without recommended extras
sudo apt-get install -y --no-install-recommends <package>
# Search for a package
apt-cache search <keyword>
# Remove a package and its config
sudo apt-get purge <package> && sudo apt-get autoremoveCommon Issues
sudo not available on a fresh VPS:
# As root, install sudo and add your user
apt-get install -y sudo
usermod -aG sudo <username>
# Then log out and back inDocker CE daemon not started after install:
sudo systemctl enable docker
sudo systemctl start docker
# Log out and back in for group membership to take effect
# (the script already runs: usermod -aG docker $USER)Docker GPG key or repository error:
# Re-add the GPG key manually
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpgkubectl not found after install:
# Verify the apt source was added correctly
cat /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update && sudo apt-get install -y kubectl