Disable root SSH login on your server
One of the first hardening steps: no more direct root connections from the internet.
01Command
$ sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config && sudo systemctl restart sshd02What it does
Bots constantly hammer root@ on any public SSH port, and PermitRootLogin no removes that target entirely: attackers must now also guess a valid username. You still have full admin access by logging in as a normal user and running sudo, so nothing is lost. Restart sshd to apply, and validate the config with sshd -t first so a typo doesn't break startup.
03Risk
04Undo
$ sudo sed -i 's/^PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config && sudo systemctl restart sshd05Sources
- sshd_config(5) — Linux manual pageEvidence: PermitRootLogin no prevents root from logging in directly via SSH; changes require restarting sshd to take effect.
- SecuringDebianHowto — Debian WikiEvidence: Disabling direct root SSH login is a core hardening step; administrators should log in as a normal user and use sudo instead.
Last verified: 2026-09-18 · Category: Security & Privacy
06Related solutions
Generate a modern Ed25519 public/private key pair in ~/.ssh for authenticating to servers and Git platforms without passwords.
Add or remove read, write, and execute permission for the owner, group, or others using symbolic or octal modes.
Add a UFW rule to permit inbound traffic on a TCP or UDP port, such as SSH on port 22.