Your first VPS feels like total freedom: a blank Linux machine, root access, and no one telling you what to do. That freedom is exactly the trap. Most of these VPS setup mistakes happen in the first hour after the root password email lands, and each one takes about five minutes to fix if you catch it early. Fix them in the order below and your server will be boring in the best possible way: quiet, patched, and recoverable.
1. Logging in as root with a password
Every VPS boots with one known username: root. Attackers know this too, and bots scan the entire internet trying common passwords against it around the clock. Logging in as root over a password is handing them half the puzzle on a plate.
The fix has three steps. First, create a normal user and give it sudo rights:
adduser deploy
usermod -aG sudo deploy
Second, set up key-based login for that user from your own machine, then copy the key over:
ssh-keygen -t ed25519
ssh-copy-id deploy@YOUR_SERVER_IP
Third, turn off password authentication and root login over SSH. Edit /etc/ssh/sshd_config and set:
PermitRootLogin prohibit-password
PasswordAuthentication no
Then reload SSH with sudo systemctl reload sshd. Keep your current SSH session open in a second terminal window while you test the new login. If something is wrong in the config, you still have a working session to fix it with instead of being locked out of your own server.
2. Skipping the firewall
A fresh VPS usually has every port wide open. You only need a handful: SSH (22), HTTP (80), and HTTPS (443) cover most first projects. Everything else is surface area you are not using yet.
On Ubuntu and Debian, UFW makes this a two-minute job. The one rule people get wrong is order: allow SSH before you enable the firewall, or you lock yourself out instantly.
sudo ufw allow OpenSSH
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable
Open 80 and 443 later, only when you have a web server running: sudo ufw allow 80,443/tcp. A firewall is not optional hardening. It is the default posture.
3. Leaving SSH on its default settings
Disabling password auth (mistake 1) removes the biggest SSH risk, but default settings still leave you noisy and exposed to constant login attempts. Two cheap improvements make a real difference.
First, install Fail2Ban. It watches your auth logs and temporarily bans IPs that fail too many logins. One command, sensible defaults out of the box:
sudo apt install fail2ban
Second, an honest word about changing the SSH port from 22. It does cut down log noise and bot traffic noticeably, and there is nothing wrong with doing it. But understand what it is: obscurity, not security. A port scan finds your SSH in seconds. Key-only auth is the actual lock; a non-standard port is just moving the doorbell. Do both if you like, but never treat the port change as the fix.
4. Never updating the server
Linux distributions ship security patches constantly. A server that was fully patched on deploy day is behind again within weeks. Unpatched services are how most small servers get compromised — not through clever zero-days, but through vulnerabilities with fixes that sat uninstalled for months.
Run updates manually when you log in:
sudo apt update && sudo apt upgrade -y
And let the server handle security patches on its own between your visits:
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
One caveat: kernel updates only take effect after a reboot. If your provider’s dashboard or needrestart tells you a reboot is pending, schedule one. A patched kernel that never booted is not patched.
5. Having no backup plan
This is the mistake that hurts the most, because you only discover it when you need the backup. A deleted directory, a bad deploy, a failed disk — without a copy somewhere else, that is the end of the story.
Get two things straight. First, your provider’s snapshot feature is convenient, but it usually lives on the same infrastructure as your server. It protects against your own mistakes, not against the provider having a bad day. A real backup lives somewhere else entirely.
Second, back up what you cannot recreate: /etc (all your configs), your application data and uploads, and database dumps. A minimal nightly job looks like this:
0 2 * * * rsync -aAX --delete /etc /var/www /home backup@BACKUP_HOST:/srv/backup/vps1/
Dump databases before the rsync runs — a live database copied mid-write can restore corrupted. Test a restore at least once. A backup you have never restored is a hope, not a plan.
6. Running a small VPS with no swap
On a 1 or 2 GB plan, one hungry process can eat all the RAM and trigger the kernel’s OOM killer, which starts terminating processes to survive. The victim is often your database or web server, and the result looks like a random crash with nothing in the logs explaining it.
A small swap file gives the kernel breathing room instead of a kill decision. Two gigabytes is a sane size for a small VPS:
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Make it survive reboots by adding this line to /etc/fstab:
/swapfile none swap sw 0 0
Then keep the kernel from leaning on swap too eagerly: sudo sysctl vm.swappiness=10, and persist it in /etc/sysctl.conf. Swap is a safety net, not extra RAM — if you are swapping constantly, you need a bigger plan, not a bigger swapfile.
7. Leaving default credentials in place
Fresh installs love default logins: database root with no password, admin panels on admin/admin, sample apps with published default secrets. Bots try these defaults specifically because so many people never change them.
Every time you install something, change its default credentials immediately, before you configure anything else. Store secrets in environment files with tight permissions (chmod 600 .env), never commit them to git, and rotate anything that was ever pasted into a chat log or a forum post. This takes two minutes per app and removes an entire class of “how did they get in” mysteries.
Your first-hour checklist
Do these in order, right after your first login:
- Create a sudo user, set up SSH keys, and disable password auth and root login.
- Allow SSH in UFW, then enable the firewall.
- Install Fail2Ban.
- Run system updates and enable unattended security upgrades.
- Set up an offsite backup job for
/etc, app data, and database dumps. - Add a swap file if you are on 2 GB of RAM or less.
- Change every default credential on every app you install.
None of this is exciting, which is the point. A well-set-up VPS is uneventful: logins fail quietly at the firewall, patches install themselves, and the backup you never think about is there on the one day you need it. Get the boring parts right first, and everything you build on top of the server gets easier. With the boring parts right, the server is ready for the projects you actually bought it for, like self-hosting n8n for automations.