How to Disable Root SSH Login
Short answerCreate a normal user with sudo, confirm SSH login as that user (preferably with a key), keep a console/noVNC session ready, then set PermitRootLogin no in sshd_config and reload SSH. Never disable root login before the sudo user works.
Overview
Disabling direct root SSH reduces brute-force noise and forces named-user administration. This is a Linux hardening step for VPSGrid unmanaged VPS plans. Related: SSH Keys vs Password Login · Enable SSH Key Authentication.
Open the browser noVNC console before changing SSH policy. Keep an existing root SSH session open until a second session works as the new sudo user.
Before you start
- You can already SSH as root
- You know your primary IP
- Console access from the client area works
1) Create a sudo user
As root:
# Ubuntu / Debian
adduser deploy
usermod -aG sudo deploy
# AlmaLinux / Rocky Linux
adduser deploy
passwd deploy
usermod -aG wheel deployReplace deploy with your preferred username. Confirm sudo works:
su - deploy
sudo -v
# enter the user password if prompted; exit back to root when done testing2) Enable SSH for that user (key recommended)
- Install the user’s public key in
~deploy/.ssh/authorized_keys(ownershipdeploy:deploy, mode700for.sshand600for the file) - From your computer, open a new terminal and test:
ssh deploy@YOUR_PRIMARY_IP
sudo whoami
# should print: rootDo not continue until this works.
3) Disable root SSH login
Edit the SSH daemon config (as root or via sudo):
sudo nano /etc/ssh/sshd_config
# or: sudo nano /etc/ssh/sshd_config.d/99-vpsgrid-hardening.confSet (or add):
PermitRootLogin noOptional stronger combo after keys work for the sudo user:
PasswordAuthentication no
PubkeyAuthentication yesValidate and reload:
# syntax check (command name varies by distro)
sudo sshd -t || sudo sshd -t -f /etc/ssh/sshd_config
# reload without dropping other sessions
sudo systemctl reload sshd 2>/dev/null || sudo systemctl reload ssh4) Verify and only then disconnect root
- From a new local terminal:
ssh deploy@YOUR_PRIMARY_IPstill works - Confirm
ssh root@YOUR_PRIMARY_IPis rejected - Only then close the old root session
Rollback if something goes wrong
- Open noVNC/console from the client area
- Log in as root locally
- Set
PermitRootLogin yes(temporarily), reload sshd, fix the sudo user/key, then harden again
Important notes
- Disabling root SSH is not the same as deleting the root account
- Windows VPS plans use RDP, not this Linux sshd setting
- VPSGrid support does not apply guest SSH hardening for you on unmanaged plans
Frequently Asked Questions
Should I disable root before adding a sudo user?
No. Always prove sudo-user SSH works first.
Can I still use root after this?
Yes via sudo -i / sudo su - after logging in as your sudo user, or via the console.
I locked myself out
Use the browser console, restore PermitRootLogin, reload sshd, then repair user/key settings.
Related Articles
Need More Help?
Open a ticket at billing.vpsgrid.net with your service ID, whether console works, and the exact sshd error after the change.
¿Le ha resultado útil esta respuesta?