Initial Server Setup: Securing Your New VPS
When you first deploy an Ubuntu or Debian VPS, the default setup allows password logins on port 22. Within minutes, automated botnets will start brute-forcing root credentials. Follow these essential steps to lock down your server.
Step 1: Generate an SSH Key Pair (On Your Local Computer)
ssh-keygen -t ed25519 -C "admin@yourdomain.com"
Copy the public key to your VPS:
ssh-copy-id -i ~/.ssh/id_ed25519.pub root@your-server-ip
Step 2: Disable Password Authentication
Edit the SSH daemon configuration file on your VPS:
sudo nano /etc/ssh/sshd_config
Update these directives:
PasswordAuthentication no
PermitRootLogin prohibit-password
Restart SSH: sudo systemctl restart ssh
Step 3: Configure UFW (Uncomplicated Firewall)
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
Now your VPS only accepts connections on authorized ports and enforces key-based authentication!