Cloud VPS

How to Set Up a Fresh Ubuntu 24.04 Cloud VPS from Scratch (Initial Config)

How to Set Up a Fresh Ubuntu 24.04 Cloud VPS from Scratch (Config) - CpanelFree Guide
Written by Blog

Complete beginner checklist to configure, update, user-harden, and firewall a brand new Ubuntu 24.04 LTS cloud VPS server in 2026.

⚡ Initial Server Setup Executive Summary (2026)

  • Core Objective: Transform an unhardened, root-accessible Ubuntu 24.04 LTS cloud instance into a production-hardened Linux server.
  • Essential Security Steps: Sudo user creation, Ed25519 SSH key enforcement, root password login lockout, and UFW stateful firewall activation.
  • Zero Maintenance Alternative: CpanelFree.com — Authentic cPanel hosting with automated security.

When you first provision a fresh cloud VPS running Ubuntu 24.04 LTS (Noble Numbat) from providers like Hetzner, DigitalOcean, Linode, or Oracle Cloud, your server starts in a highly vulnerable default state: the root user has full unrestricted access, password authentication is frequently enabled, and all network ports are wide open.

Within minutes of boot, automated botnets and malicious scrapers begin scanning port 22 with dictionary attacks. In this step-by-step masterclass, we provide the Complete 2026 Initial Server Setup Blueprint to configure, harden, and secure your new Ubuntu 24.04 cloud VPS from scratch.


Direct Answer: How Do You Set Up a Fresh Ubuntu 24.04 VPS?

Direct Answer: To configure a fresh Ubuntu 24.04 VPS: 1. Update system packages (sudo apt update && sudo apt upgrade -y), 2. Create a dedicated non-root user with sudo permissions (adduser deployer && usermod -aG sudo deployer), 3. Set up SSH key authentication, 4. Disable root login and password auth in /etc/ssh/sshd_config, and 5. Enable the UFW firewall (sudo ufw allow OpenSSH && sudo ufw enable).

📖 SSH Key Guide: Need to generate keys? Follow our masterclass on How to Create and Connect SSH Keys to Any Linux VPS.

Initial Server Setup Checklist & Security Matrix

Step # Action Item Terminal Command Security Objective
1 System Package Update sudo apt update && sudo apt upgrade -y Patch critical CVE vulnerabilities
2 Create Sudo Non-Root User adduser deployer && usermod -aG sudo deployer Eliminate catastrophic root mistakes
3 Configure Ed25519 SSH Key ssh-copy-id deployer@SERVER_IP Enforce cryptographic authentication
4 Lock Root & Passwords PasswordAuthentication no Stop 100% of brute-force bot attacks
5 Enable UFW Firewall ufw allow OpenSSH && ufw enable Block unauthorized network ports
6 Automatic Security Updates sudo apt install unattended-upgrades -y Automate daily kernel security patches

⚡ Skip Server Hardening & Get Free cPanel

Don’t want to spend hours managing Linux terminal security? Host your website with cPanel, PHP 8.3, and free SSL on CpanelFree.com.

Launch Free Web Hosting →


Step-by-Step Technical Execution Blueprint

Step 1: Create Non-Root Sudo User

Log in as root and create your deployer account:

# Update repository lists
sudo apt update && sudo apt upgrade -y

# Add deployer user
adduser deployer
usermod -aG sudo deployer

Step 2: Copy SSH Keys to New User

rsync --archive --chown=deployer:deployer ~/.ssh /home/deployer

Step 3: Harden SSH Daemon Configuration

Open SSH configuration: sudo nano /etc/ssh/sshd_config.d/50-cloud-init.conf and ensure the following rules are set:

PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
X11Forwarding no
MaxAuthTries 3

Restart SSH: sudo systemctl restart ssh.

Step 4: Configure UFW Stateful Firewall

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

Step 5: Configure Fail2ban Intrusion Prevention

Install fail2ban to automatically ban IP addresses showing repeated authentication failures:

sudo apt install fail2ban -y
sudo systemctl enable fail2ban
sudo systemctl start fail2ban

Frequently Asked Questions (FAQ)

❓ What should I do if I lock myself out of SSH?

Most cloud providers (Hetzner, DigitalOcean, Oracle) provide a Web VNC Console in their cloud dashboard that allows you to log in directly via simulated keyboard and fix SSH configurations.

❓ Should I change the default SSH port from 22?

Changing your SSH port to a custom port (e.g. 2222) stops 99% of automated mass bot scans, though enforcing SSH keys is your primary cryptographic defense.

❓ What is the next step after initial server setup?

Configure swap memory to prevent database crashes: read our guide on How to Add Swap Memory on Ubuntu 24.04 VPS.

Production Linux Hardening: Securing Shared Memory & Network Stack

After creating your non-root sudo user and configuring SSH keys, the final layer of server hardening involves securing shared memory (/dev/shm) and tuning Linux kernel sysctl parameters against SYN flood DDoS attacks.

Add the following mount parameter to /etc/fstab to prevent malicious scripts from executing out of temporary shared memory:

tmpfs /dev/shm tmpfs defaults,noexec,nosuid 0 0

Next, tune network security in /etc/sysctl.conf:

net.ipv4.tcp_syncookies = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1

Run sudo sysctl -p to load these hardening parameters immediately into the active Linux kernel.

Setting Up Server Monitoring with Netdata

To monitor real-time CPU spikes, RAM usage, and disk I/O from a web dashboard, install the open-source Netdata monitoring agent:

wget -O /tmp/netdata-kickstart.sh https://get.netdata.cloud/kickstart.sh && sh /tmp/netdata-kickstart.sh

Netdata collects thousands of per-second server metrics with less than 1% CPU overhead, giving you complete visibility into system health.

About the author

Blog

DevOps architect and Linux sysadmin specializing in server hardening, OpenLiteSpeed performance optimization, and free cloud hosting infrastructure.

Leave a Comment