Initial server setup: Ubuntu 22.04 / 24.04
The first fifteen minutes on a new VPS. Non-root user with SSH keys, automatic security updates, time sync, UFW, hostname, timezone. The baseline every other guide on this site assumes.
You have a fresh VPS. Now what?
Most provider control panels hand you the root password (or root SSH key) and call it a day. That's the starting line, not the finish. Below is the same checklist we run on every Inferno, Hetzner, Vultr, and DigitalOcean box before we install anything else.
Step 1 — Log in as root, change the password
ssh root@your-server-ip
passwd # set a strong new password if you got one in email
Step 2 — Create a non-root user
adduser deploy
usermod -aG sudo deploy
"deploy" is a convention — pick any short name. The user becomes the day-to-day account; root stays for break-glass use only.
Step 3 — Copy your SSH key to the new user
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy
ls -la /home/deploy/.ssh # confirm key is present
Open a second terminal and SSH in as deploy before closing your root session:
# Local laptop, new terminal
ssh deploy@your-server-ip
sudo whoami # should print "root" after typing password
If that works, your root session can be safely closed. If it doesn't, you still have root in the first terminal to fix it.
Step 4 — Disable root SSH and password auth
sudo nano /etc/ssh/sshd_config
Change or add:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication no
sudo systemctl restart ssh
From here, root SSH and password SSH are off. Only key-authenticated non-root users can log in. See full SSH hardening for the extended checklist.
Step 5 — System updates and automatic security upgrades
sudo apt update && sudo apt full-upgrade -y
sudo apt install -y unattended-upgrades update-notifier-common
sudo dpkg-reconfigure --priority=low unattended-upgrades
Verify it'll actually run:
sudo unattended-upgrades --dry-run
Step 6 — Firewall basics (UFW)
sudo ufw allow OpenSSH
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable
sudo ufw status verbose
Add 80/443 if you'll run a web server later. Detailed UFW + Docker patterns in UFW firewall setup.
Step 7 — Hostname and timezone
sudo hostnamectl set-hostname app-fra-01
sudo timedatectl set-timezone Europe/Helsinki
timedatectl # verify
A consistent hostname naming scheme — {role}-{region}-{number} — saves time when you have more than three boxes.
Step 8 — Time sync
Ubuntu uses systemd-timesyncd by default. Confirm it's running:
timedatectl status
# System clock synchronized: yes
# NTP service: active
For more demanding sync (TLS / OAuth tokens), install chrony:
sudo apt install -y chrony
sudo systemctl enable --now chronyd
chronyc tracking
Step 9 — Swap (for tight RAM)
On VPS plans < 4 GB, a small swap file is cheap insurance against OOM kills. See create a swap file for the full guide. Quick version:
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Step 10 — fail2ban
sudo apt install -y fail2ban
sudo systemctl enable --now fail2ban
sudo fail2ban-client status
Out of the box it watches SSH. See fail2ban install for custom jails (Nginx, Postfix, etc.).
Step 11 — A tiny convenience: bash history
cat >> ~/.bashrc <<'EOF'
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTTIMEFORMAT="%F %T "
export HISTCONTROL=ignoredups:erasedups
shopt -s histappend
EOF
source ~/.bashrc
Timestamps and bigger history pay off the day you need to remember what you ran a week ago.
Step 12 — Reboot, verify
sudo reboot
# wait 30 seconds
ssh deploy@your-server-ip
uptime
sudo ufw status
systemctl is-enabled unattended-upgrades.service fail2ban
All three should report enabled. If the SSH login works after a reboot, the server is in a good state to start installing actual workloads.
What we deliberately skip on this checklist
- SSH port change. Moving SSH off 22 reduces noise in logs but adds zero real security. Strong keys + fail2ban handle the threat.
- 2FA on SSH. Adds friction for limited gain when you already enforce key-only login. Worth it for high-value boxes or shared-team servers.
- IPv6 disable. Don't. IPv6 is on by default for a reason; disabling it breaks future-you's tools.
- Custom kernels. The provider's stock kernel is what's tested with their network and storage stack. Stay on it.
VPS for a clean Ubuntu install?
Inferno provisions Ubuntu 22.04 / 24.04 with sane defaults and a modern kernel. The $3.49 starter is enough for the baseline above plus a couple of services.
What to do next
- Extend SSH hardening beyond the basics.
- UFW with Docker — the gotchas around Docker's iptables.
- fail2ban with custom jails.
- Install Docker — the usual next step.
Author: Marek Vainionpää — SRE, Helsinki. Last tested: 2026-05-22 on Ubuntu 22.04 LTS and 24.04 LTS.