brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: PermitRootLogin has four values, and the default is not yes

Linux
~/tips/tip-ssh-permitrootlogin-prohibit-password

PermitRootLogin no

Shows the four PermitRootLogin values and how to see the one your server really uses.

“Disable root login” appears in nearly every hardening list, yet the setting has four values, and the default is milder than people fear.

In sshd_config, PermitRootLogin accepts yes, prohibit-password, forced-commands-only and no. The man page says the default is prohibit-password: root cannot log in with a password, while keys still work.

With forced-commands-only, root may log in with a public key only if the key in authorized_keys carries a command= option. That suits a backup job that logs in as root to run one command. The value no stops root logins completely:

# /etc/ssh/sshd_config.d/30-root.conf
PermitRootLogin no

To see what your server really does, ask for the effective settings instead of reading the file. A distribution can ship its own default in a drop-in, so the output is what counts:

sudo sshd -T | grep -i permitrootlogin

I would pick no wherever I can log in as a normal user and use sudo, which is almost everywhere. Some tools and appliance setups log in as root on purpose, for example for backups, so check what connects before you flip it. Test with sudo sshd -t and keep one session open while you try a new login.

Further reading: sshd_config(5)

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link