Launch offer — 30% off all VPS plans with code MARGO30. Instant provisioning in 60 seconds.
🛒0 ☻

The exact checklist our engineers run on every new box: disable password SSH, add a sudo user, configure UFW, install fail2ban, enable unattended upgrades, lock down ports and set up automated backups. Ten steps, about fifteen minutes, a dramatically smaller attack surface.

A brand-new VPS is at its most vulnerable in the first hour after provisioning. It is running a default image, the root password is often the only credential, SSH accepts passwords from anywhere, and nothing is logging failed attempts. Bots scan every public IP on the internet within minutes of it coming online, so the goal is to close the obvious doors before you deploy anything real. Here is the sequence we use on every Ubuntu 22.04 and 24.04 instance at MarGoVPS.

1. Log in as root once, then never again

Connect with ssh root@your-server-ip. You will use this root session only to create your own account. Everything after step 2 happens as a normal user with sudo.

2. Create a limited sudo user

Run adduser deploy then usermod -aG sudo deploy. This becomes your daily account. If it is ever compromised, the attacker still needs the sudo password to touch the system, and you can revoke one user instead of the whole box.

3. Copy your SSH key and disable password authentication

From your laptop, run ssh-copy-id deploy@your-server-ip. Then edit /etc/ssh/sshd_config to set PasswordAuthentication no, PermitRootLogin no and PubkeyAuthentication yes. Restart with systemctl restart ssh. This single change removes the entire class of password-guessing attacks, which is the overwhelming majority of what those scanning bots are trying.

4. Move SSH off the default port (optional but cheap)

Setting Port 2222 in the same file stops the noise from automated scanners that only probe 22. It is not real security on its own, but it keeps your auth logs readable and reduces load. Remember to open the new port in the firewall before you restart SSH, or you will lock yourself out.

5. Enable the UFW firewall, default deny inbound

Run ufw default deny incoming, ufw default allow outgoing, then allow only what you need: ufw allow 2222/tcp, ufw allow 80/tcp, ufw allow 443/tcp, and ufw enable. Every other port is now closed to the internet, including database and admin ports you may open later by accident.

6. Install and tune fail2ban

apt install fail2ban then drop a /etc/fail2ban/jail.local that bans an IP for an hour after five failed SSH attempts. Even with key-only auth, this protects any web login forms you add later and keeps your logs clean.

7. Turn on unattended security upgrades

apt install unattended-upgrades and enable them with dpkg-reconfigure -plow unattended-upgrades. Critical CVE patches now apply themselves overnight. You still control non-security updates, but you are no longer one forgotten reboot away from a known-exploited vulnerability.

8. Set the correct timezone and enable NTP

timedatectl set-timezone UTC. Accurate, consistent time matters for log correlation, cron scheduling and TLS. Ubuntu syncs via systemd-timesyncd by default; confirm it with timedatectl status.

9. Harden kernel and network sysctls

In /etc/sysctl.d/99-hardening.conf enable net.ipv4.conf.all.rp_filter=1, disable source routing, ignore ICMP broadcast requests and enable SYN cookies. Apply with sysctl --system. These blunt spoofing and low-rate SYN floods before they reach your services.

10. Schedule automated backups and test a restore

A hardened server you cannot rebuild is still a risk. Point a nightly snapshot or a restic/borg job at off-site storage, then actually restore one file on a scratch box. An untested backup is a rumour. On MarGoVPS, daily NVMe snapshots are included on every plan, so step 10 is one toggle in the dashboard.

Getting started

Run these ten steps once and you can provision future servers from a snapshot that already has them baked in. The whole pass takes about fifteen minutes and removes the failure modes behind the majority of compromised VPS incidents we see on the support desk. If you would rather start from a box that ships with SSH keys, UFW and snapshots already configured, our NVMe cloud plans boot into exactly this state.

Leave a Reply

Your email address will not be published. Required fields are marked *