# Secure a New Linux VPS in 15 Minutes (Ubuntu)

> A checklist for the first minutes on a new Linux VPS — automatic updates, a sudo user, SSH keys, no root or password login, a firewall and backups.

- Source: https://sundaecloud.in.th/en/blog/secure-new-linux-vps/
- Published: 2026-11-12 · Updated: 2026-11-25
- Category: Linux
- Tags: Linux, Ubuntu, Security, Tutorial
- Thai: https://sundaecloud.in.th/th/blog/secure-new-linux-vps.md

---

Within minutes of your VPS coming online, bots will start guessing its SSH password. Nobody is targeting you; they scan every IP address on the internet, all the time. This is a six-step checklist to finish before you install anything else. It takes about 15 minutes on **Ubuntu** (Rocky Linux is similar — use `dnf` and `firewalld` instead).

> **Before you start**
>
> Keep the Web Console from the control panel open in another tab. If an SSH or firewall change locks you out, it is always a way back in.

## 1. Keep it updated

A Sundae VPS is fully updated when it's handed over. Turn on automatic security updates so it stays patched when you forget:

```bash
sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades
```

## 2. Work as your own user, not root

Working as root all the time means one mistyped command can break the whole system. A Sundae VPS already logs you in as the user you chose when ordering, not root. Check that it has `sudo`:

```bash
sudo -v
```

On a server from elsewhere that only gives you root, create a user first with `adduser your-username` and `usermod -aG sudo your-username`.

## 3. Use SSH keys instead of passwords

An SSH key can't be guessed the way a password can. On **your own computer** (not the VPS), create a key and copy it to the server:

```bash
ssh-keygen -t ed25519 -C "you@example.com"
ssh-copy-id your-username@YOUR_VPS_IP
```

If you pasted a public key when ordering, it's already installed; skip straight to the test. Open a new terminal and run `ssh your-username@YOUR_VPS_IP`. If you get in without a password prompt, the key works.

## 4. Disable root and password logins over SSH

Once key login works, add a small config file. Name it starting with `00-`: SSH keeps the first value it reads for each setting, and other files in the same folder (such as `50-cloud-init.conf`) may turn password login back on.

```bash
sudo nano /etc/ssh/sshd_config.d/00-hardening.conf
```

with these two lines:

```text
PermitRootLogin no
PasswordAuthentication no
```

restart SSH (on Rocky Linux the service is `sshd`):

```bash
sudo systemctl restart ssh
```

and check that it took effect. Both lines should end in `no`:

```bash
sudo sshd -T | grep -Ei 'permitrootlogin|passwordauthentication'
```

> ⚠️ **Keep your current session open**
>
> Confirm you can log in from a new window before closing the old one, so a mistake can still be undone.

## 5. Turn on the firewall and open only what you use

The rule is **deny everything, then allow what you need**. On Ubuntu that's `ufw`:

```bash
sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp   # if this is a web server
sudo ufw enable
sudo ufw status
```

Always allow OpenSSH **before** `ufw enable`, or you will cut yourself off. DDoS traffic is already filtered at the network edge before it reaches the server; the on-server firewall decides which of your services are exposed at all.

## 6. Install Fail2ban

Fail2ban watches the logs and bans IPs that keep failing to log in. The defaults already protect SSH:

```bash
sudo apt install -y fail2ban
sudo systemctl enable --now fail2ban
sudo fail2ban-client status sshd
```

## Don't skip this: plan your backups

The most important step, and the one most often skipped. RAID storage covers a failed drive, but **not a deleted file, a botched update or a compromise** — and Sundae VPS does not take automatic backups for you. Set up off-server backups on day one, for example:

- `restic` or `borg` pushing to object storage
- A daily cron job that dumps your database and ships it elsewhere
- **An actual test restore**, at least once. A backup you have never restored is not a backup yet.

## The checklist

- [x] Automatic security updates on
- [x] Logged in as your own sudo user, not root
- [x] SSH keys only; root and password login disabled
- [x] `ufw` enabled with only the ports you use
- [x] Fail2ban installed
- [x] Off-server backups running, and a restore tested

With these six done, your server is already better protected than most machines on the internet. Now go install your web server, Docker or whatever you came here to run.

## Frequently asked questions

### Should I move SSH off port 22?

It isn't necessary. A different port cuts log noise from scanning bots, but what actually protects the server is key-based login with password authentication turned off.

### What if a firewall mistake locks me out of SSH?

Open the Web Console (VNC) from the control panel. It reaches the server without going over the network, so you can fix the firewall rules or SSH settings from there.

### Does the VPS come with backups?

Not at Sundae VPS — there are no automatic backups or snapshots. RAID protects against a failed drive, not against deleted files, so off-server backups are the customer's responsibility.
