This guide covers how to disable root SSH access and apply common security best practices for a public-facing Ubuntu 22.04 VPS.
sudo nano /etc/ssh/sshd_config
PermitRootLogin no
Optional: Use `prohibit-password` to allow only SSH key login for root.
sudo systemctl restart sshd
adduser youruser usermod -aG sudo youruser
On your local machine:
ssh-keygen -t ed25519 ssh-copy-id [email protected]
In /etc/ssh/sshd_config, ensure:
PasswordAuthentication no
sudo apt update && sudo apt upgrade
sudo apt install unattended-upgrades sudo dpkg-reconfigure --priority=low unattended-upgrades
sudo ufw allow OpenSSH sudo ufw enable
Protects against brute-force SSH attacks.
sudo apt install fail2ban
In /etc/ssh/sshd_config, modify:
Port 2222
Reduces automated scan noise.
sudo ss -tuln
Options include:
journalctllogwatchAlready covered via `unattended-upgrades`.
Ubuntu uses it by default. Verify with:
sudo aa-status
Use `rsync`, `restic`, or cloud snapshot tools.
Edit with:
sudo visudo
Tools like `libpam-google-authenticator`.
Last reviewed: 06/06/2025