Why root login is dangerous
Root + password = easy target for bots. One weak password = full server compromise.
The secure way (best practice in 2025):
Steps:
- Create a normal sudo user
adduser admin
usermod -aG sudo admin
- Set up SSH key authentication
mkdir -p /home/admin/.ssh
chmod 700 /home/admin/.ssh
chown admin:admin /home/admin/.ssh
- Add public key
# On your local machine: copy public key
cat ~/.ssh/id_ed25519.pub # or id_rsa.pub
# On server (as admin user):
nano ~/.ssh/authorized_keys # paste the key
chmod 600 ~/.ssh/authorized_keys
- Test login
ssh admin@YOUR_SERVER_IP
- Disable root & password login
PermitRootLogin no
PasswordAuthentication no
Restart SSH:
sudo systemctl restart ssh
Done!
Your server is now way harder to hack.
Use ed25519 keys (faster & more secure):
ssh-keygen -t ed25519 -C "your@email.com"

Top comments (0)