Initial server setup on Ubuntu
The first steps to get your freshly created server configured, safe and ready for production.
When you spin up a fresh 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 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
- 1Login 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.
- 2Update the system and packages on Ubuntu Server How to update your Ubuntu server to the latest packages and security patches.
- 3Create a Linux User on Ubuntu Server Learn how to create a non-root user on your Ubuntu server for improved security and better management.
- 4Grant 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.
- 5Enabling 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.
- 6Disabled Password-Based Authentication Learn how to disable password-based SSH authentication for a non-root user on your Ubuntu server.
- 7Enable And Configure Firewall on Ubuntu Server Learn how to enable and configure the firewall on your Ubuntu server to enhance security.
- 8Install Fail2Ban on Ubuntu Server In this guide we will install fail2ban on your ubuntu server to further improve system protection
- 9Enable Unattended Security Upgrades on Ubuntu Server Learn how to enable unattended security upgrades on your Ubuntu server to automatically install security updates.
