To disable root login and password authentication over SSH on Debian 13, put PasswordAuthentication no, KbdInteractiveAuthentication no and PermitRootLogin no in a file that sorts first in /etc/ssh/sshd_config.d/, check it with sshd -t, reload with systemctl reload ssh, and prove it from your PC: a password-only login must end in Permission denied (publickey). Do it only after an SSH key login works in a second terminal, then add a daily job that installs updates and reboots only when a package asks for it.
This guide goes deeper than the full Debian 13 hardening checklist on SSH keys from Windows, Mac and Linux, brute force in the Debian 13 log, and a daily cron upgrade job. Every command ran on a fresh Debian 13.7 container on our lab server on the night of 20 to 21 November 2026 (timestamps in the output are UTC), with OpenSSH 10.0p2. It works the same on any of our Linux VPS and VDS plans in Amsterdam, Dublin and Prishtina, which come with full root access.
Quick fix, as root on the server
- Keep your current SSH session open. Open a second terminal and log in with your key:
ssh -o PasswordAuthentication=no deploy@YOUR_SERVER_IP. Stop here if it fails.- Write the drop-in file (four lines, shown below) to
/etc/ssh/sshd_config.d/00-vps-hardening.conf.sshd -t && systemctl reload ssh- Check:
sshd -T | grep -E "permitrootlogin|passwordauthentication|kbdinteractive"must printnothree times.- From your PC:
ssh -o PubkeyAuthentication=no deploy@YOUR_SERVER_IPmust sayPermission denied (publickey).
Key facts, checked on 21 November 2026:
- Debian 13 ships OpenSSH 10.0 with
PermitRootLogin prohibit-passwordandPasswordAuthentication yesas effective defaults. Root cannot log in with a password, but every other account can, until you change it. - OpenSSH uses the first value it reads for each keyword (sshd_config manual), and Debian reads
/etc/ssh/sshd_config.d/*.confat the top of the main file. A file named00-...wins over a50-cloud-init.conf. - Since OpenSSH 9.8, failed logins are written by a process called
sshd-session, and the server penalises addresses that keep failing (OpenSSH 9.8 release notes). Debian 12 has OpenSSH 9.2 and neither feature. - Debian 13 no longer has
lastb(trixie release notes, 5.1.9), and Debian 12 and 13 have no/var/log/auth.logunless you install rsyslog (bookworm release notes, 5.1.7). Read SSH failures withjournalctl -u ssh. - A SANS honeypot saw the first SSH brute force on port 22 less than 2 minutes after it went online (SANS ISC, 2013). A 2026 SANS diary counted over 20 million SSH brute-force attempts in about 100 days on its sensors, most aimed at
root(SANS ISC, June 2026).
Step 1: a sudo user, so root never logs in
As root, create your everyday account and put it in the sudo group. adduser asks for a password: pick a strong one, because sudo will ask for it later. It is never used for SSH once passwords are off.
adduser deploy
usermod -aG sudo deploy
id deploy
uid=1000(deploy) gid=1000(deploy) groups=1000(deploy),27(sudo),100(users)
27(sudo) is what you need to see. If the account already exists, skip adduser and only add the group.
Step 2: SSH key login on Debian 13 from your PC
The key is made on your own computer, not on the server. The private file stays with you; only the .pub file goes to the server.
Make the key (Windows PowerShell, Mac, Linux)
The command is the same on all three. Windows 10 and 11 include OpenSSH, and in PowerShell ssh-keygen saves to C:\Users\you\.ssh\ (Microsoft: key-based authentication in OpenSSH). Press Enter for the default file and type a passphrase when asked:
ssh-keygen -t ed25519 -C "my-laptop"
Generating public/private ed25519 key pair.
Your identification has been saved in /home/laptop/.ssh/id_ed25519
Your public key has been saved in /home/laptop/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:s0gKjfIO1G398HEMqVTidV6oPgihXIGCyg0/R2foCiY laptop@home
On our Windows PC (OpenSSH_for_Windows 9.5p2) the result was the same two files. The passphrase protects the private file if your laptop is stolen; it is never sent to the server.
Copy the public key to the server
On Mac and Linux, ssh-copy-id logs in once with the account password and appends the key:
ssh-copy-id deploy@YOUR_SERVER_IP
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Number of key(s) added: 1
Windows has no ssh-copy-id. In PowerShell, send the file through ssh and let the server append it. Replace the address, and type the deploy password when asked:
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh deploy@YOUR_SERVER_IP "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
We ran the quoted server part from a Linux client in the lab; it appended the key and left authorized_keys at -rw-------. Use >>, never >, or you erase existing keys.
Test in a second terminal before you change anything
Leave the first session open. In a new window, force a key-only login so a password fallback cannot fool you:
ssh -o PasswordAuthentication=no deploy@YOUR_SERVER_IP
Ours logged in, and the server log recorded which key was used:
sshd-session[3819]: Accepted publickey for deploy from 10.141.188.224 port 36200 ssh2: ED25519 SHA256:s0gKjfIO1G398HEMqVTidV6oPgihXIGCyg0/R2foCiY
The fingerprint matches the one ssh-keygen printed: the right key works. If you get Permission denied (publickey), fix it now while passwords still work; the checklist has a table of causes.
Why brute force matters: what Debian 13 actually logs
A brute-force bot connects to port 22 and tries names such as root, admin and ubuntu with lists of common and leaked passwords, from many addresses. With password authentication on, every account with a weak or reused password is one lucky guess away, and credential stuffing tries passwords leaked from other sites. We sent eight wrong passwords to the fresh container before hardening. The Debian 13 journal:
journalctl -u ssh --since today --no-pager | grep -E "Failed password|Invalid user|penalty"
sshd-session[3652]: Failed password for root from 10.141.188.224 port 60300 ssh2
sshd-session[3669]: Invalid user admin from 10.141.188.224 port 50250
sshd-session[3669]: Failed password for invalid user admin from 10.141.188.224 port 50250 ssh2
sshd-session[3679]: Failed password for deploy from 10.141.188.224 port 50264 ssh2
...
sshd[1830]: drop connection #0 from [10.141.188.224]:33912 on [10.141.188.224]:22 penalty: failed authentication
The deploy line is the real risk: an existing account, open to guessing. After six failures OpenSSH's built-in penalty dropped our next two connections before a password was asked. That slows one bot down; it does not stop a botnet with thousands of addresses.
To count attempts on your own server, by user and by source address:
journalctl -u ssh --since today --no-pager | grep -c "Failed password"
journalctl -u ssh --since today --no-pager | grep -oE "Failed password for (invalid user )?[^ ]+" | sort | uniq -c | sort -rn
6
2 Failed password for root
2 Failed password for invalid user admin
1 Failed password for invalid user ubuntu
1 Failed password for deploy
These are lab numbers; on a public IP, run the same lines a day after install. On Debian 13 lastb is gone and our /var/log/btmp stayed at 0 bytes after those failures, so use the journal.
A key ends the guessing game. Ed25519 has "a nominal strength of 128 bits" (RFC 8032, section 8.5), far beyond anything a bot can try, and the server never sees your private key, so there is nothing to guess and nothing a phishing site can capture and replay.
Step 3: disable root login and password authentication over SSH
Check what is already in the drop-in folder. Our container had nothing there; a server built with cloud-init may have a 50-cloud-init.conf that sets PasswordAuthentication yes:
ls -l /etc/ssh/sshd_config.d/
grep -rn -E "PasswordAuthentication|PermitRootLogin|KbdInteractive" /etc/ssh/sshd_config.d/
Then, as root in your first session, write the file. If you followed the hub checklist you already have this exact file; skip to the checks.
cat > /etc/ssh/sshd_config.d/00-vps-hardening.conf <<'EOF'
PubkeyAuthentication yes
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
EOF
sshd -t
sshd -T | grep -E "permitrootlogin|passwordauthentication|kbdinteractive"
permitrootlogin no
passwordauthentication no
kbdinteractiveauthentication no
A silent sshd -t means the syntax is fine. sshd -T prints what the server will really use, which is the only value that counts.
Why the file starts with 00. We added a 50-cloud-init.conf with PasswordAuthentication yes on purpose. With our file named 00-, the result was no. Renamed to 60-, the same check printed passwordauthentication yes. Lines added at the bottom of /etc/ssh/sshd_config lose the same way, because the Include line is near the top.
Apply it. On Debian the service is ssh, not sshd, and it is not socket-activated: our container had ssh.service enabled and ssh.socket disabled. A reload keeps your open session:
sshd -t && systemctl reload ssh
Prove it from your PC
Three tests from the second terminal. Key login still works:
ssh deploy@YOUR_SERVER_IP 'echo "logged in as $(whoami) on $(hostname)"'
logged in as deploy on lab-debssh
Password login is refused without even asking for a password:
ssh -o PubkeyAuthentication=no deploy@YOUR_SERVER_IP
deploy@10.141.188.224: Permission denied (publickey).
With -v the client shows Authentications that can continue: publickey. Root is refused even with a valid key (we copied the deploy key to root for this test):
root@10.141.188.224: Permission denied (publickey).
sshd-session[3860]: ROOT LOGIN REFUSED FROM 10.141.188.224 port 36212 [preauth]
Only now close the first session. For work as root, log in as deploy and type sudo -i.
Step 4: Debian automatic updates, the native way
Our minimal container did not have unattended-upgrades. After apt install -y unattended-upgrades, the package had written /etc/apt/apt.conf.d/20auto-upgrades with both lines at "1", and apt-daily-upgrade.timer was scheduled, so it was on without further steps. Debian's default "auto-installs security updates, but not new features" (Debian wiki). Our automatic security updates guide covers the dry run, needrestart and an hourly emergency mode, so here only the two choices people ask about.
To also take the trixie-updates archive (stable-updates) and reboot at 04:00 when a kernel needs it, add a local file instead of editing 50unattended-upgrades:
cat > /etc/apt/apt.conf.d/52unattended-upgrades-local <<'EOF'
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=${distro_codename}-updates";
};
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";
EOF
unattended-upgrade --dry-run -d 2>&1 | grep "Allowed origins"
Allowed origins are: origin=Debian,codename=trixie,label=Debian, origin=Debian,codename=trixie,label=Debian-Security, origin=Debian,codename=trixie-security,label=Debian-Security, origin=Debian,codename=trixie-updates
The list adds up, so the stock origins stay. For security-only, comment out the "origin=Debian,codename=${distro_codename},label=Debian"; line in 50unattended-upgrades; that line brings in point-release fixes from the main archive.
Step 5: a daily apt upgrade with cron, logged, reboot only when needed
Some admins want one plain job: update, upgrade, log, reboot only if needed. The signal is the file /var/run/reboot-required, with the packages listed in /var/run/reboot-required.pkgs. On Debian 13 the kernel part of that signal comes from the unattended-upgrades package: it installs the hook /etc/kernel/postinst.d/unattended-upgrades, which touches the file after a kernel install. Without that package our container had an empty /etc/kernel/postinst.d/, and linux-base 4.12.1 in trixie does not create the file either (Debian added that in linux-base 4.13, bug #1010699). So keep unattended-upgrades installed even if this cron job does the upgrading. Pick this job or unattended-upgrades as your main tool, so you always know which one did what.
Save the script as root:
nano /usr/local/sbin/daily-apt-upgrade
#!/bin/sh
# Daily package update + upgrade. Logs to /var/log/daily-apt-upgrade.log.
# Reboots only when a package asks for it (/var/run/reboot-required).
PATH=/usr/sbin:/usr/bin:/sbin:/bin
export DEBIAN_FRONTEND=noninteractive
LOG=/var/log/daily-apt-upgrade.log
APT_OPTS="-q -y -o DPkg::Lock::Timeout=600 -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold"
{
echo "=== $(date "+%F %T") start"
if ! apt-get $APT_OPTS update; then
echo "apt-get update failed, nothing upgraded"
exit 1
fi
apt-get $APT_OPTS --with-new-pkgs upgrade
echo "apt-get upgrade exit code: $?"
if [ -f /var/run/reboot-required ]; then
echo "reboot required by: $(tr "\n" " " < /var/run/reboot-required.pkgs 2>/dev/null)"
shutdown -r +5 "daily-apt-upgrade: reboot required"
fi
echo "=== $(date "+%F %T") end"
} >> "$LOG" 2>&1
In plain words: PATH is set because cron gives jobs a very short one. DPkg::Lock::Timeout=600 waits up to 10 minutes if apt is busy. The Dpkg::Options keep your edited config files, so no question can hang the job. --with-new-pkgs lets the upgrade pull in new packages such as a new kernel, but it "will never remove packages" (apt-get manual), unlike full-upgrade. The reboot waits 5 minutes; shutdown -c cancels it.
Make it executable, check the syntax, add the cron line for 03:30 every night and run it once by hand:
chmod 700 /usr/local/sbin/daily-apt-upgrade
sh -n /usr/local/sbin/daily-apt-upgrade && echo syntax-ok
echo "30 3 * * * root /usr/local/sbin/daily-apt-upgrade" > /etc/cron.d/daily-apt-upgrade
/usr/local/sbin/daily-apt-upgrade
cat /var/log/daily-apt-upgrade.log
syntax-ok
=== 2026-11-20 23:05:11 start
Hit:1 http://deb.debian.org/debian trixie InRelease
Hit:2 http://deb.debian.org/debian trixie-updates InRelease
Hit:3 http://deb.debian.org/debian-security trixie-security InRelease
...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
apt-get upgrade exit code: 0
=== 2026-11-20 23:05:12 end
A file in /etc/cron.d has a user column (root); with crontab -e as root, drop that word. To see cron really fire it, we set the line to every minute for a test:
journalctl -u cron --no-pager | grep daily-apt-upgrade
CRON[3982]: (root) CMD (/usr/local/sbin/daily-apt-upgrade)
We tested the reboot branch by creating the flag file by hand with a made-up package name; shutdown -c then cancelled the reboot:
reboot required by: linux-image-6.12.57+deb13-amd64
Reboot scheduled for Fri 2026-11-20 23:10:24 UTC, use 'shutdown -c' to cancel.
Later, grep -E "start|upgraded|reboot" /var/log/daily-apt-upgrade.log | tail -20 shows the last nights at a glance. A kernel fix only protects you after that reboot; our NoisyTCP kernel check shows how to compare the running kernel with the installed one.
Be honest about the risk of blind upgrades
Debian stable changes little inside a release, but a third-party repository (Docker, PHP from sury.org, a database vendor) can ship a new major version that this job installs without asking. Freeze what must not move with apt-mark hold PACKAGE, and keep backups you have restored at least once. Every RS Computers server has free weekly backups (the last two kept) that you restore yourself; our backup and restore guide shows how, and how to add a daily off-server copy.
Bonus: fail2ban on Debian 13, and one lab trap
With passwords off, fail2ban is optional and mostly cuts log noise. Allow SSH in your firewall first (the checklist covers nftables). Debian's package already enables the sshd jail with the journal backend in /etc/fail2ban/jail.d/defaults-debian.conf; one file sets the limits:
apt install -y fail2ban
printf "[sshd]\nenabled = true\nmaxretry = 5\nfindtime = 10m\nbantime = 1h\n" > /etc/fail2ban/jail.d/sshd-local.conf
systemctl restart fail2ban
fail2ban-client status sshd
Five failed key logins from another address got it banned, and new connections were refused:
| |- Total failed: 5
| `- Journal matches: _SYSTEMD_UNIT=ssh.service + _COMM=sshd
|- Currently banned: 1
`- Banned IP list: 10.141.188.1
The trap: our first test, from the server's own IP, counted 0 failures. Fail2ban ignores the server's own addresses by default, so always test from a different machine.
Debian 12 vs Debian 13: what changes in this guide
| Item | Debian 12 (bookworm) | Debian 13 (trixie) |
|---|---|---|
| OpenSSH server | 9.2p1 (package page) | 10.0p2 in our lab |
| Process name in SSH log lines | sshd[PID] | sshd-session[PID] for logins, sshd for the listener |
| Built-in penalty for failing addresses | No (added in OpenSSH 9.8) | On by default |
lastb | Available | Removed; use the journal |
/var/log/auth.log | Only with rsyslog installed | Only with rsyslog installed |
| Drop-in folder and defaults | Include sshd_config.d, root prohibit-password, passwords on | Same |
| DSA keys | Disabled by default | Not supported at all |
| Commands in this guide | Work as written; logs say bookworm | Tested as written |
Debian 12 rows come from the bookworm sshd_config and the release notes above; our lab ran Debian 13 only.
Checklist
| Step | Proof it worked |
|---|---|
| Sudo user | id deploy shows 27(sudo) |
| Key login | Accepted publickey for deploy in journalctl -u ssh |
| Drop-in active | sshd -T prints no for root login, passwords and keyboard-interactive |
| Passwords refused | Permission denied (publickey). with -o PubkeyAuthentication=no |
| Root refused | ROOT LOGIN REFUSED in the log |
| Daily updates | Dry run lists your origins, or /var/log/daily-apt-upgrade.log has a fresh entry |
| Backups | One restore done, not just a backup taken |
Frequently asked questions
How do I disable password authentication for SSH on Debian 13?
Create /etc/ssh/sshd_config.d/00-vps-hardening.conf with PasswordAuthentication no and KbdInteractiveAuthentication no, run sshd -t, then systemctl reload ssh. Check with sshd -T | grep passwordauthentication. Test a key login in a second terminal first, or you can lock yourself out.
Why does PasswordAuthentication no not work on my Debian server?
Usually another file in /etc/ssh/sshd_config.d/, often 50-cloud-init.conf, sets yes and is read first, because OpenSSH keeps the first value it finds. Name your file 00-... so it sorts first, and confirm with sshd -T. In our lab, the same file named 60-... lost to a cloud-init file.
Is PermitRootLogin prohibit-password enough?
It blocks root passwords but still lets root in with a key. PermitRootLogin no forces everyone through a named sudo account, so the log shows who did what and a stolen root key is useless for SSH. Debian 13's default is prohibit-password.
Where is auth.log on Debian 13?
There is none by default, because Debian stopped installing rsyslog in Debian 12. Use journalctl -u ssh, for example journalctl -u ssh --since today | grep "Failed password". lastb was removed in Debian 13.
Do SSH keys stop brute force completely?
They stop it from working. Bots still connect and fail, but with password authentication off there is no password to guess. OpenSSH 10 on Debian 13 also slows repeat offenders; fail2ban can ban them if the noise bothers you.
Is a daily apt upgrade in cron safe on Debian?
With only Debian's own repositories it is low risk, because updates inside a stable release are fixes. Use --with-new-pkgs upgrade rather than full-upgrade, keep config files with --force-confold, hold packages that must not change and keep tested backups.
Need a hand?
If you are starting a fresh server, our Linux VPS and VDS plans run on NVMe in Amsterdam, Dublin or Prishtina, with Debian 13 ready in under 60 seconds after payment. VPS plans share vCPUs; VDS plans have dedicated vCPUs, the better choice if an upgrade night must not slow your sites, and they are on the dedicated vCPU page. If you want this hardening, a custom setup or a whole system built for you, we do custom offers quoted per job: write to us on Telegram or by email at info@rscomputers-ks.com.