Initial server setup on Ubuntu

The first steps to get your freshly created server configured, safe and ready for production.

32 min 9 steps
UbuntuServerSecurity

When you spin up a fresh ubuntu logo Ubuntu server — whether it’s a VPS from DigitalOcean, Hetzner, or any other provider — it comes with a bare-bones configuration that is not production-ready. Before deploying anything, you need to take a few important steps to lock things down and set up a solid foundation.

This guide walks you through the essential first steps every server should go through before hosting anything.

What You’ll Learn

  • Updating your system to the latest packages and security patches.
  • Creating a dedicated non-root deploy user with sudo privileges and SSH access.
  • Enabling and configuring the firewall to restrict unwanted traffic.

Prerequisites

  • A VPS or server running ubuntu logo Ubuntu 22.04 or 24.04.
  • Root access to the server (usually provided by your hosting provider).
  • A SSH key pair. (check out Generating an SSH Key Pair for instructions).

Steps

  1. 1
    Login as root to Your Server via SSH Learn how to securely log in as the root user to your server using SSH from your local machine, on any operating system.
    1 min
  2. 2
    Update the system and packages on Ubuntu Server How to update your Ubuntu server to the latest packages and security patches.
    2 min
  3. 3
    Create a Linux User on Ubuntu Server Learn how to create a non-root user on your Ubuntu server for improved security and better management.
    1 min
  4. 4
    Grant administrative privileges to user on Ubuntu server Learn how to add a non-root user to the sudo group on your Ubuntu server to grant administrative privileges.
    1 min
  5. 5
    Enabling External Access for Your Regular User on Ubuntu Server Learn how to enable external SSH access for a non-root user on your Ubuntu server, ensuring secure and efficient remote management.
    10 min
  6. 6
    Disabled Password-Based Authentication Learn how to disable password-based SSH authentication for a non-root user on your Ubuntu server.
    2 min
  7. 7
    Enable And Configure Firewall on Ubuntu Server Learn how to enable and configure the firewall on your Ubuntu server to enhance security.
    1 min
  8. 8
    Install Fail2Ban on Ubuntu Server In this guide we will install fail2ban on your ubuntu server to further improve system protection
    1 min
  9. 9
    Enable Unattended Security Upgrades on Ubuntu Server Learn how to enable unattended security upgrades on your Ubuntu server to automatically install security updates.
    3 min
Conclusion and Next Steps Wrapping up the initial server setup process and outlining the next steps to take after securing your Ubuntu server.
1 min