After deploying a new Ubuntu 22.04 server, you should perform a few essential configuration steps before putting it into production. This guide covers creating a non-root user, configuring a basic firewall, and enabling automatic security updates.
Prerequisites
- A running Ubuntu 22.04 server
- SSH access as root
Step 1 — Update the System
Connect to your server and update all packages:
$apt update && apt upgrade -yHit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
...
Reading package lists... Done
Building dependency tree... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.Step 2 — Create a Non-Root User
Running as root is a security risk. Create a regular user with sudo privileges:
$adduser deployFollow the prompts to set a password. Then add the user to the sudo group:
$usermod -aG sudo deployStep 3 — Copy SSH Key to the New User
$rsync --archive --chown=deploy:deploy ~/.ssh /home/deployTest the new user in a separate terminal before logging out of root:
$ssh deploy@YOUR_SERVER_IPStep 4 — Disable Root SSH Login
Edit the SSH daemon configuration:
$nano /etc/ssh/sshd_configFind and update these lines:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yesRestart SSH:
$systemctl restart sshd[!WARNING] Ensure you can log in as your new user with SSH key authentication before disabling root login. Otherwise you may lock yourself out.
Step 5 — Configure UFW Firewall
Install and configure UFW (Uncomplicated Firewall):
$ufw allow OpenSSH$ufw enableCommand may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startupCheck the status:
$ufw status verboseStatus: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
22/tcp (OpenSSH) ALLOW IN AnywhereStep 6 — Enable Automatic Security Updates
$apt install unattended-upgrades -y$dpkg-reconfigure --priority=low unattended-upgradesSelect Yes when prompted to automatically download and install stable updates.
Step 7 — Set the Timezone
$timedatectl set-timezone America/New_YorkVerify:
$timedatectl Local time: Thu 2026-04-24 10:00:00 EDT
Universal time: Thu 2026-04-24 14:00:00 UTC
RTC time: Thu 2026-04-24 14:00:00
Time zone: America/New_York (EDT, -0400)Next Steps
Your server is now configured with basic security hardening. Continue with:
