Securing SSH Access on Your VPS
SSH is the primary way to access your VPS. By hardening SSH, you significantly reduce the risk of unauthorized logins.
Step 1: Change Default SSH Port
Edit the SSH configuration file:
sudo nano /etc/ssh/sshd_config
Find Port 22
and change it to another port (e.g. 2222
).
Step 2: Disable Root Login
Inside the same file, set:
PermitRootLogin no
Step 3: Use Key-Based Authentication
On your local machine, generate a key pair:
ssh-keygen -t rsa -b 4096
Then copy the public key to your VPS:
ssh-copy-id -i ~/.ssh/id_rsa.pub user@your-vps-ip
Step 4: Restart SSH
sudo systemctl restart ssh
✅ Your VPS is now protected with stronger SSH security.