Home › Root servers › Secure SSH
Secure SSH
Disable password login and root login.
The settings go into their own file under /etc/ssh/sshd_config.d/. This survives system updates better than changes to the main configuration.
- Create the file:
sudo nano /etc/ssh/sshd_config.d/10-haertung.conf - Content:
PasswordAuthentication no KbdInteractiveAuthentication no PermitRootLogin prohibit-passwordThe line
PermitRootLogin prohibit-passwordallows root to log in with a key only. Password login for root is blocked, key login remains possible. This is useful as an emergency access if the normal user no longer works. WithPermitRootLogin no, root would be blocked completely.The file
10-haertung.confdeliberately starts with 10. The files insshd_config.dare read in alphabetical order, and the first value found applies. Many systems place default values in a later file, which this one overrides. - Check the configuration and reload the service:
sudo sshd -t sudo systemctl reload ssh - Log in from a second terminal before closing the old session.
If the login stops working, the open session remains as a way back. The last resort is console access, see IPMI and console.