CompareHostingOnline

Home / Guides / How to secure a new VPS: a first-hour hardening checklist

Guide

How to secure a new VPS: a first-hour hardening checklist

A step-by-step checklist for securing a new unmanaged VPS: updates, a non-root user, SSH keys, a firewall, automatic updates, backups and monitoring.

By Muhammad Hamza, Founder & EditorUpdated Nov 30, 2026

Short answer

On a new unmanaged VPS, update the system, create a non-root user, log in with SSH keys, turn on a firewall, keep automatic security updates on and take backups. These steps stop most common attacks.

Last verified Nov 28, 2026 · How we test
At a glance
  • Why does a new VPS need hardening?A freshly created VPS is reachable from the whole internet within a minute, and automated scanners find new addresses quickly.
  • What should you do in the first hour?Install all pending package updates, then reboot if the kernel changed.
  • How do you secure SSH?SSH is the front door.

Why does a new VPS need hardening?

A freshly created VPS is reachable from the whole internet within a minute, and automated scanners find new addresses quickly. Logs on a new server often show login attempts within the first hour. Default settings are designed to get you started, not to resist attack. Hardening reduces what an attacker can reach and what they can do if they get in.

The good news is that a short routine covers most of the risk. This checklist assumes a Linux server such as Ubuntu or Debian. Commands vary slightly by distribution, so use your provider’s and distribution’s documentation for exact syntax.

What should you do in the first hour?

  1. Update everything

    Install all pending package updates, then reboot if the kernel changed.

  2. Create a normal user

    Give it sudo rights and stop using root for daily work.

  3. Set up SSH keys

    Add your public key and test the login before changing anything else.

  4. Turn on a firewall

    Allow only the ports you need, such as SSH, HTTP and HTTPS.

  5. Enable automatic security updates

    So fixes arrive without you remembering.

  6. Take a snapshot and a backup

    Record a clean starting point.

How do you secure SSH?

SSH is the front door. Use key-based authentication, which is far harder to guess than any password. Generate a key pair on your own computer, copy the public key to the server, test that you can log in with it, and only then turn off password authentication and direct root login in the SSH daemon configuration. Always keep a second session open while you change SSH settings, so a mistake does not lock you out.

Changing the default port is optional and gives little real protection, but it reduces log noise. A tool that blocks repeated failed logins adds another layer. Our guide to what SSH access is explains the basics, and the OpenSSH manual lists every setting.

How do you set up a firewall?

A host firewall allows only the connections you want. On Ubuntu, the Uncomplicated Firewall (UFW) is a simple front end: allow SSH first so you do not cut yourself off, allow the web ports if you run a site, then enable it. Many providers also offer a network-level firewall in their control panel, which blocks traffic before it reaches the server; using both is a good practice.

Review open ports from time to time. Services you installed and forgot, such as a database listening on a public address, are a common cause of breaches. Databases should listen only on the local address unless you have a reason and a firewall rule to allow others.

How do you keep the system updated?

Most attacks use known flaws that have fixes available. Turn on automatic security updates for the operating system, and schedule time to update application software, such as your CMS and its plugins, language runtimes and containers. Know which versions you run and when they stop being supported. Our guides on PHP versions and WordPress requirements show how to check.

When a kernel update needs a reboot, plan it, or use a live patching service if your distribution offers one.

What else should you secure?

How do you back up and monitor?

Snapshots are quick and useful, but they usually live with the same provider. Add a file-and-database backup to separate storage, and test a restore, as described in website backups. Monitor uptime from outside with a free service, watch disk space and memory, and read the authentication log from time to time. Alerts that reach you at the right time are worth more than dashboards you never open.

What should you do if you think the server is compromised?

If you do not want to carry this responsibility, a managed plan moves most of it to the provider.

  1. Isolate it

    Block traffic with the provider firewall or take a snapshot and shut it down.

  2. Preserve evidence

    Keep logs and a disk snapshot for investigation.

  3. Rebuild, do not clean

    Create a fresh server from a known good image and restore data from a clean backup.

  4. Rotate every secret

    Change passwords, keys and API tokens that were on the server.

A worked example: the first hour on a new server

A developer creates a VPS at 10:00. At 10:05 they log in as root with the password the provider emailed and immediately update packages. At 10:15 they create a user, add their SSH key and test a login in a second window. At 10:25 they disable password and root login, restart the SSH service and confirm the key login still works. At 10:30 they enable the firewall, allowing only SSH, HTTP and HTTPS, and turn on automatic security updates. At 10:40 they check the authentication log and already see failed logins from several countries, all rejected. At 10:50 they take a snapshot and set up an off-server backup of the site folder and database.

An hour later the server is far safer than it was, and the owner has a clean snapshot to return to. The log lines are a reminder that the internet is probing every new address.

What should you review every month?

  • Pending updates and whether any need a reboot.
  • The authentication log for unusual logins.
  • Open ports and running services.
  • Free disk space and memory.
  • Backups: do they exist, are they recent and have you restored one lately?

Sources and further reading

Common questions

Is a new VPS secure by default?

No. A new server is open to the internet immediately and has default settings designed for convenience. Update it, create a non-root user, use SSH keys and a firewall, and enable automatic security updates before you rely on it.

Should I disable SSH password login?

Yes, once key-based login works. Keys are far harder to guess than passwords. Test the key login in a second session before you disable passwords or root login so a mistake does not lock you out.

How often should I update my VPS?

Turn on automatic security updates and review other updates at least monthly. Plan reboots for kernel updates. Keep application software, such as your CMS and plugins, updated and on supported versions.

Do I need a firewall on a VPS?

Yes. A host firewall such as UFW allows only the ports you use, and many providers also offer a network firewall. Use both. Keep databases listening on the local address unless you have a specific need and a rule.

What should I do if my VPS is hacked?

Isolate it, keep logs and a snapshot for investigation, rebuild from a clean image rather than trying to clean it, restore data from a known good backup and rotate every password, key and token that was on the server.

Related

More guides

Esc

Use the arrow keys, then Enter.