Skip to content

Initial Debian server setup — what differs from Ubuntu

Debian needs a slightly different first-30-minutes sequence than Ubuntu: sudo is not installed by default, the firewall is missing, and the SSH defaults are stricter. Here is the operator-grade walkthrough.

A stock Debian 12 (bookworm) image is leaner than Ubuntu’s, which is mostly a good thing — fewer surprises, fewer services running by default. But the leanness means several conveniences are missing: sudo is not installed, no firewall is present, nano may not be either, and the default user is just root. The first 30 minutes follow the same sequence as Ubuntu, with a handful of Debian-specific adjustments. This article documents what we change.

How to verify

Inventory what the image actually shipped with.

cat /etc/debian_version
uname -r
dpkg -l | grep -E '^ii  (sudo|ufw|nftables|openssh-server)' || true
ss -tlnp | grep sshd
systemctl is-active ssh
timedatectl status | head -4

If dpkg -l | grep sudo returns nothing, you are about to need it. If ufw is also missing, the firewall step requires installation, not just configuration.

What’s happening

Debian’s design philosophy is “stable and minimal.” That ships you a system without sudo, without a firewall, with SSH only listening on the default port, and with no automatic upgrade mechanism enabled. Cloud providers patch around this with their own first-boot scripts (some inject an SSH key into root, some create a debian user), but you cannot rely on a consistent state across providers. The procedure below normalizes the host so it looks like the rest of your fleet regardless of where the image came from.

A second Debian-specific point: the SSH service is named ssh (not sshd as on some other distros). The unattended-upgrades package exists but is not enabled by default, and the apt-listchanges integration is more verbose than on Ubuntu. We turn both on with sensible defaults.

The procedure

  1. Update apt and install the missing essentials. Run this from your initial root session.

    apt update
    apt full-upgrade -y
    apt install -y sudo ufw curl ca-certificates gnupg lsb-release \
                   unattended-upgrades apt-listchanges chrony
    apt autoremove --purge -y

    chrony replaces systemd-timesyncd for slightly better time accuracy and easier diagnostics; on small VMs either is fine.

  2. Create a named operator user. Debian’s adduser is interactive; the --gecos "" flag skips the comment prompts.

    adduser --gecos "" ops
    usermod -aG sudo ops
    install -d -m 0700 -o ops -g ops /home/ops/.ssh

    On Debian, the sudo group is what /etc/sudoers grants — there is no admin group like on older Ubuntu releases. See sudo-best-practices.

  3. Install your SSH public key. Same as Ubuntu — paste the key, fix the perms, and test from a second session before continuing.

    nano /home/ops/.ssh/authorized_keys
    chmod 0600 /home/ops/.ssh/authorized_keys
    chown ops:ops /home/ops/.ssh/authorized_keys
  4. Harden sshd_config. Debian 12 still ships with a monolithic /etc/ssh/sshd_config, but it also reads from /etc/ssh/sshd_config.d/*.conf if you drop a file there. The cleaner pattern is the drop-in:

    sudo tee /etc/ssh/sshd_config.d/10-hardening.conf > /dev/null <<'EOF'
    PermitRootLogin no
    PasswordAuthentication no
    KbdInteractiveAuthentication no
    PubkeyAuthentication yes
    X11Forwarding no
    EOF
    sudo sshd -t
    sudo systemctl reload ssh

    Cross-reference ssh-hardening-port-ciphers for cipher and KEX tightening.

  5. Enable UFW with a default-deny posture. UFW on Debian 12 sits on top of nftables; both work. Allow SSH first, then enable.

    sudo ufw default deny incoming
    sudo ufw default allow outgoing
    sudo ufw allow OpenSSH
    sudo ufw enable
    sudo ufw status verbose
  6. Configure chrony for time sync. Debian’s chrony picks the Debian NTP pool by default; on a fleet you typically want internal NTP sources or time.cloudflare.com.

    sudo sed -i 's|^pool .*|pool time.cloudflare.com iburst nts|' /etc/chrony/chrony.conf
    sudo systemctl restart chrony
    chronyc tracking
    chronyc sources -v

    chronyc tracking should show Stratum ≤ 3 and Leap status: Normal.

  7. Set hostname and locale. Debian images often ship with POSIX only; setting en_CA.UTF-8 (or your team’s locale) prevents some applications from misbehaving on Unicode input.

    sudo hostnamectl set-hostname app-01.prod.example.net
    sudo apt install -y locales
    sudo sed -i 's/# *en_CA.UTF-8/en_CA.UTF-8/' /etc/locale.gen
    sudo locale-gen
    sudo update-locale LANG=en_CA.UTF-8
  8. Enable unattended-upgrades for the security channel. The default config on Debian only ticks security; check the origin pattern matches what the package archive actually publishes.

    sudo dpkg-reconfigure -plow unattended-upgrades
    grep -E 'Debian-Security|Allowed-Origins' /etc/apt/apt.conf.d/50unattended-upgrades
    sudo unattended-upgrade --dry-run -d 2>&1 | tail -20

    See unattended-upgrades-debian for the deeper config, including needrestart integration and reboot windows.

  9. Add swap if the image has none. Same calculus as Ubuntu — small VMs benefit from a 1–2 GB swap file so the OOM killer is not the only memory-pressure release valve. See linux-add-swap-file.

  10. Reboot if a new kernel was installed, then verify the whole stack from your workstation.

    ssh ops@app-01.prod.example.net '
      cat /etc/debian_version
      uname -r
      systemctl is-active ssh chrony unattended-upgrades
      sudo ufw status
      timedatectl | grep "synchronized"
    '

    All checks should be green before any application package is installed.

Common pitfalls

  • Trying sudo before installing it — Debian’s stock image has none, and the original root session is the only way to add it.
  • Editing the monolithic sshd_config and missing that a drop-in file overrides it; always run sshd -T | grep -i passwordauthentication to see what is actually in effect.
  • Leaving the locale as POSIX — Python, Perl and Node tooling all complain, and some emit warnings into logs that drown real issues.
  • Assuming unattended-upgrades is enabled because the package is installed; on Debian the timer must be turned on and the origins reviewed.
  • Forgetting that Debian’s ssh service may take 10–15 seconds longer than Ubuntu to come up on a slow VM after reboot — wait before declaring it broken.

In our fleet, Ubuntu and Debian hosts run side-by-side under the same operating runbook — the differences are absorbed in the provisioning step, then both look identical to monitoring and patch management. That uniform layer is what Managed Operations provides for clients running a mixed distribution estate.