Secure a new Linux VPS in 15 minutes (2027 checklist for Ubuntu 24.04)
A fresh VPS on a public IP gets SSH login attempts within minutes. These steps take about 15 minutes on Ubuntu 24.04 and close the common holes before you install anything else.
1. Update everything
apt update && apt -y full-upgrade reboot 2. Create a sudo user
adduser deploy usermod -aG sudo deploy 3. Log in with an SSH key, not a password
On your own computer:
ssh-keygen -t ed25519 -C "you@laptop" ssh-copy-id deploy@YOUR_SERVER_IP Open a new terminal and confirm ssh deploy@YOUR_SERVER_IP works before the next step.
4. Turn off root and password logins
sudo tee /etc/ssh/sshd_config.d/00-hardening.conf <<'EOF' PermitRootLogin no PasswordAuthentication no KbdInteractiveAuthentication no EOF sudo sshd -t && sudo systemctl reload ssh The 00- name matters: sshd uses the first value it reads, and cloud images often ship 50-cloud-init.conf with password login on. sshd -t checks the config first, so a typo cannot lock you out. Keep your current session open until a fresh login works.
5. Firewall: allow only what you serve
sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow OpenSSH sudo ufw allow 80,443/tcp # only if you run a website sudo ufw enable sudo ufw status verbose Note: ports published by Docker with -p bypass ufw. Bind them to 127.0.0.1 and put a reverse proxy in front.
6. Ban repeated SSH failures
sudo apt -y install fail2ban sudo tee /etc/fail2ban/jail.local <<'EOF' [sshd] enabled = true maxretry = 5 bantime = 1h EOF sudo systemctl enable --now fail2ban sudo fail2ban-client status sshd 7. Install security updates automatically
sudo apt -y install unattended-upgrades sudo dpkg-reconfigure -plow unattended-upgrades 8. Set the time zone and check what is listening
sudo timedatectl set-timezone Asia/Kolkata sudo ss -tulpn Every line in ss -tulpn that listens on 0.0.0.0 or [::] is reachable from the internet unless the firewall blocks it. If you do not recognise a service, find out what it is before you go further.
9. Backups are your job
Snapshots from a host are convenient, but keep your own off-server copy too (for example restic to object storage) and test a restore once.
What the host should handle
A hardened server still goes offline if its IP is flooded. Choose a VPS whose network filters DDoS attacks on every port instead of null-routing your IP. Inservers KVM VPS in India run on AMD EPYC 7C13 with NVMe at Yotta D1 (Delhi NCR), with a dedicated static IPv4 and always-on Cloudflare Magic Transit in front of the network: Linux VPS in India.