Skip to content
Wallet live · USDT TRC20 · USDT BEP20 · BTC · ETH · SOL · XMR Free SSL · Malware scan · Instant image 24/7 desk · @rexahost
RexaHostRexaHost

VPS

New Linux VPS Security Checklist: The First Hour

· 6 min read

New Linux VPS Security Checklist: The First Hour

Bots start probing a new server within minutes. The ten steps to complete in your first hour on a Linux VPS, with copy-paste commands for Ubuntu, Debian, AlmaLinux and Rocky.

Key takeaways

  • Update the system, create a sudo user and switch to SSH keys before anything else.
  • Disable root and password login over SSH once your key works.
  • Enable a firewall that allows only SSH and the ports your services need.
  • Add Fail2ban and automatic security updates to handle the routine threats.
  • Set up backups and basic monitoring on day one, not after the first incident.

A brand-new VPS is a clean slate, and also a target. Automated scanners sweep public IP ranges constantly, trying common usernames and passwords on SSH. None of this is personal; it is background noise on the internet. The good news is that a short, methodical setup makes your server a much harder target than most of what those bots find. This checklist takes under an hour and works on Ubuntu 24.04, Debian 12, AlmaLinux and Rocky Linux.

Before you start: keep a back door open

Several steps change how you log in. Keep your first SSH session open while you test changes in a second window, so a mistake does not lock you out. If it happens anyway, the VPS console in your client area gives direct access.

Step 1: Update everything

Your OS image may be weeks old. Install the latest patches first.

  • Ubuntu / Debian: apt update && apt upgrade -y
  • AlmaLinux / Rocky: dnf upgrade -y

Reboot if a new kernel was installed: reboot.

Step 2: Set the hostname and time zone

  • hostnamectl set-hostname web1
  • timedatectl set-timezone UTC (UTC keeps logs consistent across servers)

Step 3: Create a non-root user with sudo

  • Ubuntu / Debian: adduser deploy then usermod -aG sudo deploy
  • AlmaLinux / Rocky: adduser deploy, passwd deploy, then usermod -aG wheel deploy

Working as a normal user and elevating with sudo limits the damage of mistakes and makes actions traceable in logs.

Step 4: Set up SSH key authentication

On your own computer, create a key if you do not have one:

  • ssh-keygen -t ed25519 -C "you@laptop"

Copy it to the server:

  • ssh-copy-id deploy@YOUR_SERVER_IP

On Windows without ssh-copy-id, paste the contents of your .pub file into /home/deploy/.ssh/authorized_keys on the server and set permissions: chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys.

Now open a new terminal and confirm ssh deploy@YOUR_SERVER_IP logs in without a password.

Step 5: Harden the SSH daemon

Edit /etc/ssh/sshd_config (or add a file in /etc/ssh/sshd_config.d/) and set:

  • PermitRootLogin no
  • PasswordAuthentication no
  • KbdInteractiveAuthentication no
  • MaxAuthTries 3

Test the configuration with sudo sshd -t, then restart: sudo systemctl restart ssh (Ubuntu/Debian) or sudo systemctl restart sshd (AlmaLinux/Rocky). Confirm you can still log in from a second window before closing the first.

Step 6: Enable a firewall

Ubuntu / Debian with UFW

  1. sudo apt install ufw
  2. sudo ufw default deny incoming
  3. sudo ufw default allow outgoing
  4. sudo ufw allow OpenSSH
  5. sudo ufw allow 80,443/tcp (only if you will host websites)
  6. sudo ufw enable

AlmaLinux / Rocky with firewalld

  1. sudo systemctl enable --now firewalld
  2. sudo firewall-cmd --permanent --add-service=ssh
  3. sudo firewall-cmd --permanent --add-service=http --add-service=https
  4. sudo firewall-cmd --reload

Databases such as MySQL or Redis should not be open to the internet. Bind them to localhost or allow only specific IPs.

Step 7: Install Fail2ban

Fail2ban watches logs and temporarily bans IPs that repeatedly fail to authenticate.

  • Ubuntu / Debian: sudo apt install fail2ban
  • AlmaLinux / Rocky: sudo dnf install epel-release && sudo dnf install fail2ban

Create /etc/fail2ban/jail.local with an [sshd] section containing enabled = true, then sudo systemctl enable --now fail2ban. Check status with sudo fail2ban-client status sshd.

Step 8: Automatic security updates

  • Ubuntu / Debian: sudo apt install unattended-upgrades then sudo dpkg-reconfigure -plow unattended-upgrades
  • AlmaLinux / Rocky: sudo dnf install dnf-automatic, set apply_updates = yes in /etc/dnf/automatic.conf, then sudo systemctl enable --now dnf-automatic.timer

Security patches then install without you remembering. Plan occasional reboots for kernel updates.

Step 9: Remove what you do not need

  • List listening services: sudo ss -tulpn
  • Stop and disable anything you do not recognise or need: sudo systemctl disable --now SERVICE
  • Fewer services means fewer things to patch and fewer doors to knock on.

Step 10: Backups and monitoring

Security is also about recovery. A compromised or broken server is far less painful with a recent backup stored somewhere else. Follow the 3-2-1 approach in our VPS backup strategy guide.

For monitoring, start simple:

  • An external uptime checker that alerts you if the site or SSH port stops responding.
  • A disk space alert, because full disks break databases and logs.
  • A weekly glance at sudo journalctl -p warning --since "7 days ago" and last for unexpected logins.

Going further: optional hardening

The ten steps above cover the threats most servers actually face. Once they are in place, consider these extra layers depending on what you run:

  • Two-factor authentication for SSH. Tools such as Google Authenticator's PAM module add a one-time code to key-based logins. Useful when several people administer the server.
  • A VPN for admin access. Put SSH and admin panels behind a WireGuard tunnel so they are invisible to the public internet. See our guide to a self-hosted WireGuard VPN.
  • Web application firewall rules. For public websites, a WAF in front of the application filters common injection and brute-force attempts.
  • Audit logging. The auditd service records sensitive file changes and command execution for later review.
  • Separate servers for separate roles. Keeping the database on a private network apart from the web server limits what an attacker reaches if one layer is breached.

What to do if you suspect a compromise

Signs include unknown processes using CPU, unexpected outbound traffic, new user accounts or modified system files. If you see them, do not just delete the obvious file and carry on. Take a snapshot or copy of logs for investigation, rotate every credential stored on the server, and in most cases rebuild from a clean image and restore data from a backup taken before the incident. Then work out how the attacker got in, so the same gap is closed on the new server.

The checklist at a glance

#TaskWhy it matters
1Update packagesCloses known vulnerabilities
2Hostname and UTC timeClear logs and identification
3Sudo userLimits root exposure
4SSH keysDefeats password guessing
5Harden sshdNo root, no passwords
6FirewallOnly needed ports open
7Fail2banBans repeated offenders
8Auto updatesPatches without reminders
9Remove servicesSmaller attack surface
10Backups and monitoringFast detection and recovery

Common mistakes

  • Disabling passwords before testing the key. Always test in a second window.
  • Enabling the firewall without allowing SSH. Add the SSH rule first.
  • Exposing admin panels publicly. Put phpMyAdmin or dashboards behind a VPN, IP allow-list or authentication.
  • Running apps as root. Use dedicated service users.
  • Forgetting Docker bypasses UFW. Published container ports can skip UFW rules; bind them to 127.0.0.1 or use Docker-aware firewalling.

Your responsibilities under the abuse policy

A compromised server can be used to send spam, host phishing or attack others, and that activity is removed under the abuse policy regardless of who caused it. Hardening protects your data and also keeps your service in good standing.

Where to go next

With the basics in place, install your stack. Our guides on installing WordPress on a VPS and getting started with Docker pick up from here.

Need a server to practise on? VPS Starter (1 vCPU, 1 GB RAM, 25 GB NVMe) costs $2.78 a month, and VPS Basic with 2 GB is $5.98. See every size on the Linux VPS page.

Frequently asked questions

How quickly do attackers find a new VPS?

Automated scanners sweep the entire IPv4 space continuously, so login attempts on SSH often begin within minutes to hours of a server going online.

Should I change the SSH port?

Changing the port reduces log noise from bots but is not real security. SSH keys and disabled password login are what actually protect you.

Is UFW or firewalld better?

Use the default for your distribution: UFW on Ubuntu and Debian, firewalld on AlmaLinux and Rocky. Both do the job well.

Do I need antivirus on a Linux VPS?

Usually not for a typical web server. Updates, minimal services, strong authentication and file integrity awareness matter more. Mail servers handling attachments are an exception.

What if I lock myself out of SSH?

Use the VPS console in your client area to log in directly and fix the SSH or firewall configuration.

#linux vps security#ssh hardening#ufw#fail2ban#server security#vps checklist

Plans in this article

Servers mentioned here

VPS Starter

Standard
$1.89 /mo
$2.50Save 24% billed monthly
  • 1 vCPU
  • 1 GB RAM
  • 25 GB NVMe
  • 1 TB traffic
  • Root access · dedicated IPv4
  • Ashburn · London · Amsterdam · Frankfurt +6

VPS Basic

Standard
$2.79 /mo
$5.38Save 48% billed monthly
  • 1 vCPU
  • 2 GB RAM
  • 60 GB NVMe
  • 3 TB traffic
  • Root access · dedicated IPv4
  • Ashburn · London · Amsterdam · Frankfurt +6
Most popular

VPS Pro

Standard
$4.69 /mo
$10.42Save 55% billed monthly
  • 2 vCPU
  • 4 GB RAM
  • 120 GB NVMe
  • 5 TB traffic
  • Root access · dedicated IPv4
  • Ashburn · London · Amsterdam · Frankfurt +6

Keep reading

Related articles

Live Chat · offline