You just bought a VPS. You have an IP address, a root password or an SSH key, and a project you want online by tonight. Before you install Nginx, Node, PHP or anything else, give the server half an hour of attention first.
Here is why. The moment a server gets a public IP, bots start knocking. They scan whole IP ranges all day, looking for SSH with weak passwords, open databases and forgotten admin panels. They are not after you in particular. They try every server they find, and a fresh, unpatched box with password login turned on is the easiest one to get into.
The good news: the basics take about 30 minutes, and they stop the large majority of these attacks. This guide walks through them step by step on Ubuntu, with notes for Debian where it differs. No security background needed. If you can copy a command and read what it prints, you can do this.
The checklist at a glance
| # | Step | Time | What it stops |
|---|---|---|---|
| 1 | Update everything | 5 min | Known, already-fixed security holes |
| 2 | Create your own user with sudo | 2 min | Working as root all day |
| 3 | Log in with an SSH key | 5 min | Password guessing |
| 4 | Turn off password and root login | 5 min | Brute-force attacks on SSH |
| 5 | Turn on the firewall | 3 min | Services you exposed by accident |
| 6 | Install Fail2ban | 3 min | Bots that keep hammering the door |
| 7 | Turn on automatic security updates | 3 min | Forgetting to patch next month |
| 8 | Check what is listening | 2 min | Databases open to the whole internet |
One rule before you start: keep your current SSH session open until the very end. Every time you change how login works, test it from a second terminal window. If something breaks, the open session is your way back in.
1. Update everything first
A fresh image can be weeks or months old. Some of the packages on it may already have public security fixes waiting.
2. Create your own user
Doing everything as root is like driving with no seatbelt. One wrong command (say, rm -rf in the wrong folder) and nothing stops you. Create a normal user and give it sudo, so you have to ask for admin rights on purpose:
3. Log in with an SSH key, not a password
A password can be guessed. An SSH key in practice cannot. A key comes as a pair: a private key that never leaves your computer, and a public key that you copy to the server.
4. Turn off password login and root login
This one step does the most. Once passwords are off, those bots guessing admin123 all day get nowhere. It also shuts out bugs like SSHole, which in November 2026 let a long nonsense password log in on some Alpine Linux servers.
5. Turn on the firewall
A firewall decides which ports anyone can reach. The rule is simple: block everything coming in, then open only what you need. Ubuntu comes with ufw (on Debian, run sudo apt install ufw first).
6. Install Fail2ban
With passwords off, nobody can guess their way into SSH. Bots will still try thousands of times, though, filling your logs and wasting CPU. Fail2ban watches for repeated failed logins and blocks those IPs for a while.
This is the short version. The full guide, with every step and source, is on GeekSpark.

