No KYC · seven Linux VPS plans, one price in six cities · Pay in BTC, USDT, USDC, ETH, SOL, LTC, XMR
Language: English
Configure a VPS

Guide · security · checked 16 November 2026

How do I secure a Linux VPS?

Last updated: · 4 min read

Quick answer

How do I secure a Linux VPS?

To secure a Linux VPS, log in with an SSH key, create a sudo user, turn off root and password login, allow only needed ports in a firewall, add Fail2ban, enable automatic security updates and keep backups elsewhere. A SaltVPS server can start key-only from checkout, which covers step 1 of these 8.

In brief
  • First hour: keys, a sudo user, root login off, firewall on.
  • First day: Fail2ban and automatic security updates.
  • First week: a tested backup stored on another machine.
  • Order matters: always allow SSH in the firewall before you enable it.
  • Same steps on Debian and Ubuntu; AlmaLinux and Rocky Linux differ in package names.

How do you secure a Linux VPS step by step?

Work in this order and keep one SSH session open until each change is tested from a second one.

  1. Use an SSH key

    Paste a public key at checkout, or add one to /root/.ssh/authorized_keys and test it before going further.

  2. Update the system

    Run apt update && apt upgrade on Debian and Ubuntu, or dnf upgrade on AlmaLinux and Rocky Linux. Reboot if a new kernel was installed.

  3. Create a sudo user

    Add a normal user with admin rights and copy your key to it, so daily work no longer runs as root.

  4. Lock down SSH

    In /etc/ssh/sshd_config, set PermitRootLogin no and PasswordAuthentication no, check with sshd -t, then restart the SSH service.

  5. Turn on a firewall

    Deny incoming traffic by default and allow SSH plus the ports your apps use. ufw does this on Debian and Ubuntu, firewalld on AlmaLinux and Rocky.

  6. Install Fail2ban

    Fail2ban reads the SSH log and bans addresses that fail to log in too many times.

  7. Enable automatic security updates

    unattended-upgrades on Debian and Ubuntu, dnf-automatic on AlmaLinux and Rocky, so patches land without a login.

  8. Back up off the server

    Send encrypted copies of data and configs to another machine, then test a restore.

Which tool handles each security step on each system?

Debian and Ubuntu share one set of tools; AlmaLinux and Rocky Linux share another.

Security tools by step on Debian or Ubuntu and on AlmaLinux or Rocky Linux
StepDebian / UbuntuAlmaLinux / Rocky LinuxDetailed guide
Admin useradduser, group sudouseradd, group wheelSudo user guide
Firewallufwfirewalld (firewall-cmd)Firewall guide
Login bansfail2ban from aptfail2ban from EPELFail2ban guide
Security patchesunattended-upgradesdnf-automaticAutomatic updates guide
Backupsrestic or rsyncrestic or rsyncBackup guide
SSH service namesshsshdFirst SSH login page

Why do SSH keys matter more than anything else?

Bots try passwords on port 22 of every public IPv4 address, all day. A key-only login makes those guesses useless, because no password is accepted at all. The rest of this list only reduces noise and limits damage.

On SaltVPS, a public key pasted at checkout is installed for root and password login stays off. Without a key, the team sets a temporary root password; change it with passwd, then follow the first SSH login page to move to a key.

What should you do in the first hour on a new VPS?

Create the admin user, close root login and turn on the firewall, in that order. Each has its own guide:

Then test a fresh login as the new user from a second terminal. Only close the root session when that works.

What does a VPS host already handle, and what is left to you?

On an unmanaged KVM server, the host runs the hardware and network; the operating system is yours. SaltVPS checked its plan list on 16 November 2026: none of the 7 plans includes backups, and outbound port 25 is closed on every server. So patches, firewall rules and copies of your data are your job.

KVM gives each server its own kernel, so a neighbour cannot change your system. The KVM explainer covers what that isolation means. Reboot, reinstall and delete are sent from the dashboard and carried out by a person; a reinstall erases the disk, which is one more reason to keep backups elsewhere.

Linux VPS security: questions

Should I change the SSH port?

It cuts log noise but adds little real protection. Keys and Fail2ban do the actual work. If you change it, allow the new port in the firewall first.

Is Ubuntu or Debian more secure on a VPS?

Both get regular security updates. What matters more is applying them, using keys and keeping few services open.

What is the best way to secure a Linux VPS in 2026?

Key-only SSH, no root login, a default-deny firewall, Fail2ban, automatic security updates and tested off-server backups. Nothing on that list costs money.

Do I need antivirus on a Linux VPS?

Usually not for a server you run yourself. Updates, few open ports and least-privilege users matter more.

How do I see who logged in?

Run last for recent logins, and journalctl -u ssh (or -u sshd) for SSH attempts.

Verdict
  • Securing a Linux VPS starts with SSH keys; the firewall, Fail2ban and updates come next.
  • Backups are the last line: no SaltVPS plan includes them, so store copies on another machine.
Sources (3)
  1. Ubuntu Server documentation: security — Canonical (2026-11-16)
  2. Securing Debian Manual — Debian (2026-11-16)
  3. sshd_config(5) manual page — OpenBSD project (2026-11-16)

Start from a key-only server

Paste your SSH public key at checkout and root logs in with it only, password login off.

From $2.25/mo on 12 months · no KYC

Configure