How-to

Enable SSH on Debian 13 and Debian 12

Debian images we install already run SSH, since that is how you log in. This guide covers fresh installs elsewhere, a re-enabled service and checking an existing setup.

Is SSH already running on my Debian machine?

On a machine from us, yes. Every Debian 13 and Debian 12 install comes with the OpenSSH server active, the root password shown in the panel and any public keys you picked placed in root's authorized_keys. The steps below matter when you install Debian yourself, for example in a virtual machine on your own hypervisor, when someone removed the package, or when you want to confirm everything is as it should be. Check the current state first:

systemctl is-enabled ssh; systemctl is-active ssh
dpkg -l openssh-server | tail -1

Two lines saying enabled and active mean you are done with installation and can skip to hardening.

How do I install the OpenSSH server?

From the default repositories. The Debian installer's software selection screen offers an "SSH server" task; if it was left unticked, install the package by hand from a local console:

apt update
apt install --no-install-recommends openssh-server

The package generates fresh host keys in /etc/ssh/, writes a default sshd_config and enables the ssh unit. Debian 13 "trixie" ships OpenSSH 10.0, while Debian 12 "bookworm" ships 9.2. The newer release drops DSA keys entirely and prefers a post-quantum hybrid key exchange, so very old clients may need an update to connect.

How do I start it and make it survive reboots?

systemctl enable --now ssh
systemctl status ssh --no-pager -l

On Debian the unit is named ssh, with sshd kept as an alias. Look for active (running) and a line saying the server is listening on port 22. If it failed, journalctl -u ssh -b --no-pager | tail -30 shows the reason, often a syntax error in a configuration file or a port already in use.

Does Debian block SSH with a firewall?

A plain Debian install has no active firewall rules, so port 22 is reachable as soon as the service starts. That is convenient, but on a public address you will want a ruleset. Debian uses nftables by default; a minimal input policy that keeps SSH and web traffic open looks like this:

#!/usr/sbin/nft -f
flush ruleset
table inet filter {
  chain input {
    type filter hook input priority filter
    policy drop
    ct state vmap { established : accept, related : accept, invalid : drop }
    iif lo accept
    ip protocol icmp accept
    tcp dport { 22, 80, 443 } accept
  }
}

Save it as /etc/nftables.conf, then run nft -c -f /etc/nftables.conf to check it and systemctl enable --now nftables to load it. If you prefer ufw, install it and allow OpenSSH before running ufw enable.

How do I check the host key before trusting it?

Print the fingerprint on the server, then compare it with what your client shows on the first connection:

for k in /etc/ssh/ssh_host_*_key.pub; do ssh-keygen -lf "$k"; done

Your client will display the ED25519 fingerprint in the form SHA256:.... Matching values prove you are talking to your machine and not something in between. After a reinstall from the panel, the host keys change, so expect the warning and remove the old entry with ssh-keygen -R followed by the address.

What should I change right after enabling SSH?

  • Create a personal user with adduser deploy and add it to the sudo group.
  • Copy your public key to that user and confirm key login works, as described in Log in with an SSH key.
  • Turn off password logins in a drop-in under /etc/ssh/sshd_config.d/.
  • Restrict or disable direct root login, covered in SSH root login settings.
  • Install unattended-upgrades so security fixes for OpenSSH land without waiting for you.

Why can't I connect even though the service runs?

Work from the outside in: is the address right, is the port open, is the service listening on the public interface? ss -tlnp | grep sshd on the server shows the listening addresses. If it lists only 127.0.0.1:22, a ListenAddress line limits it. If nothing is listed, the service is not running. Our page on Fix "Connection refused" walks through each case.

Keep Reading

Debian

Debian 13 or 12 for servers that should change as little as possible between upgrades, on any machine we sell.

Open

SSH root login settings

What each PermitRootLogin value does, how to move daily work to a sudo user and when key-only root login is reasonable.

Open

Log in with an SSH key

Create an ed25519 key, install it on your machine through the panel or ssh-copy-id, and log in without typing the root password.

Open

Fix "Connection refused"

Work out why port 22 says no: sshd stopped, wrong port, a firewall reject rule, a loopback-only listener or a machine still installing.

Open

FAQ

Quick Answers

No. SSH is installed and running on every Debian machine at delivery, and the panel shows the root password.

The unit is ssh, with sshd as an alias, so systemctl restart ssh restarts the server.

Debian 13 ships OpenSSH 10.0. Debian 12 ships OpenSSH 9.2.

No rules are active on a plain install. Add an nftables ruleset or ufw once SSH is working.

Reinstalling the machine creates new host keys. Remove the old entry with ssh-keygen -R and accept the new fingerprint after checking it.