Skip to content
Menu

How do you secure a new Linux VPS in the first 15 minutes?

Checked by the BuyMoneroVPS deskLast updated on 6 min read

Straight answer

To secure a new Linux VPS, update every package, create a normal user with sudo, copy your SSH key to it, switch off password logins, turn on unattended upgrades and enable a firewall that keeps port 22 open. On a BuyMoneroVPS Debian or Ubuntu server the 6 tasks take about 15 minutes, right after the first root login.

In brief
  • Start with apt update and apt full-upgrade: a fresh image can be weeks behind.
  • Work as a named user with sudo, and keep root for emergencies.
  • Test every SSH change from a second terminal before closing the first one.
  • Unattended upgrades install security fixes daily; ufw closes every port you do not use.

What does a fresh BuyMoneroVPS server look like?

A clean install of the system you picked, a public IPv4, a /64 of IPv6 and root access over SSH. If you pasted a public key at checkout, root logs in with that key only and password login is off. If you left the field empty, a person set a temporary root password, shown in the dashboard under "Root login with a temporary password"; change it with passwd at the first login.

Nothing else is installed or opened for you, which is the point: the server does only what you add. The commands below are for the Debian 13, Debian 12, Ubuntu 24.04 and Ubuntu 22.04 images. AlmaLinux 10 and Rocky Linux 10 follow the same plan with dnf and their own package names. The KVM VPS explainer describes what the virtual machine gives you, kernel included.

What are the 6 tasks, in order?

  1. Log in and update everything

    Connect as root, change the temporary password with passwd if you have one, then run apt update and apt full-upgrade. Reboot if a new kernel was installed.

  2. Create your own user

    Run adduser with a name of your choice and answer the prompts. Then add that user to the sudo group, as Debian's and Ubuntu's documentation both show.

  3. Give the user your SSH key

    Copy root's authorized_keys file to the new user, or run ssh-copy-id from your computer. Only the owner may write to authorized_keys.

  4. Test the new login in a second terminal

    Open a new terminal, log in as the user and run sudo -v. Group membership applies at login, so a fresh session is required.

  5. Switch off password logins

    Set PasswordAuthentication no in a file under /etc/ssh/sshd_config.d/, test with sshd -t and restart the ssh service. Keep the first terminal open until a key login works.

  6. Turn on updates and a firewall

    Install unattended-upgrades, check that it is enabled, then allow SSH in ufw before you enable it.

Tasks 1 to 3, as root (replace alice)
passwd                      # only if you got a temporary root password
apt update && apt full-upgrade -y

adduser alice
adduser alice sudo

mkdir -p /home/alice/.ssh
cp /root/.ssh/authorized_keys /home/alice/.ssh/
chown -R alice:alice /home/alice/.ssh
chmod 700 /home/alice/.ssh
chmod 600 /home/alice/.ssh/authorized_keys
Tasks 5 and 6, as alice with sudo
echo 'PasswordAuthentication no' | sudo tee /etc/ssh/sshd_config.d/10-no-passwords.conf
sudo sshd -t && sudo systemctl restart ssh.service

sudo apt install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades
sudo unattended-upgrade -v --dry-run

sudo ufw allow 22/tcp
sudo ufw enable
sudo ufw status verbose

What does each task protect against?

First-login hardening tasks for a Debian or Ubuntu VPS and what each one stops, 30 November 2026
TaskMain commandWhat it stopsTime
Update packagesapt full-upgradeKnown flaws already fixed upstream2 to 5 min
Named sudo useradduser alice sudoWorking as root by habit1 min
Key on the userssh-copy-id or cpLosing access when root login is limited1 min
No password loginsPasswordAuthentication noPassword guessing by bots2 min
Unattended upgradesdpkg-reconfigure unattended-upgradesUnpatched weeks between logins2 min
Firewallufw enableServices left listening by mistake2 min

Why do unattended upgrades matter on a small server?

Because a VPS you rarely log in to still needs its security fixes the day they ship. Ubuntu's documentation explains that /etc/apt/apt.conf.d/20auto-upgrades holds two settings, APT::Periodic::Update-Package-Lists and APT::Periodic::Unattended-Upgrade, each a number of days; 1 means daily and 0 turns it off. The behaviour itself, such as reboots or blocked packages, lives in 50unattended-upgrades.

On Debian, the wiki suggests running dpkg-reconfigure unattended-upgrades, which asks whether to download and install stable updates on its own; answer yes. Each run logs to /var/log/unattended-upgrades/. A dry run, unattended-upgrade -v --dry-run, shows what would happen without changing anything, which is a good check right after setup.

Should you also block root logins?

With a key-only setup, root over SSH is already limited to key holders; going further is a choice, not a must. The OpenSSH default for PermitRootLogin is prohibit-password, which refuses passwords for root but accepts keys. Setting it to no forces every login through your named user and sudo. Ubuntu's user-management page also shows passwd -l root to lock root's password entirely.

Whichever you choose, keep one tested way in. If SSH breaks and no session is left open, write to support; a reinstall with a new public key is the last resort, since it erases the disk.

According to BuyMoneroVPS's survey of 30 November 2026, the smallest plan, Ring 1 at $3.78, costs 47% less than the $7.08 average of 8 comparable offers. The next steps are the ufw firewall guide and, if you started with a temporary password, disabling SSH password login. No key yet? Create an SSH key first.

Frequently asked questions

Do I have to change the SSH port?

No. Moving SSH off port 22 only reduces log noise; keys and a firewall do the real work. If you move it, open the new port in ufw before restarting SSH, or you will lock yourself out.

Is fail2ban needed with key-only logins?

It is optional. Without passwords, guessing attempts cannot succeed, though they still fill the logs. ufw's limit rule, which blocks an address after 6 connections in 30 seconds, gives a similar effect with less setup.

Will unattended upgrades reboot my server?

Only if you allow it: reboots are a setting in /etc/apt/apt.conf.d/50unattended-upgrades. Read that file once; if reboots are off, reboot by hand after kernel updates.

I locked myself out. What now?

Write to support first. If access cannot be restored, request a reinstall from the dashboard with a new public key; the reinstall erases the disk, so keep backups.

Does BuyMoneroVPS harden the server for me?

No. The team installs a clean system with your key or a temporary password and leaves the rest to you, so nothing runs that you did not choose.

Verdict
  • Fifteen minutes of setup closes the gaps that bots try first.
  • Test every SSH change in a second session before closing the first.
  • Let unattended upgrades and ufw do the routine work afterwards.
Sources (6)
  1. Automatic updates — Ubuntu Server documentation (read 2026-11-30)
  2. UnattendedUpgrades (PeriodicUpdates) — Debian Wiki (read 2026-11-30)
  3. sudo — Debian Wiki (read 2026-11-30)
  4. User management — Ubuntu Server documentation (read 2026-11-30)
  5. OpenSSH server — Ubuntu Server documentation (read 2026-11-30)
  6. sshd_config(5) manual page — OpenBSD (read 2026-11-30)

Start from a clean Debian or Ubuntu server

Ring 2: 1 vCPU · 2 GB memory · 40 GB NVMe disk · 4 TB monthly transfer, root over SSH, paid in Monero with no ID and no email.

Deploy a Monero VPS from $3.78/mo