Get 20% discount on Hosting Packages + Free Domain & SSL!
Learn More

Ubuntu Server Security Settings: The First 5 Steps

Ubuntu Server Security Settings: The First 5 Steps

Top 5 Security Steps After Getting a New Ubuntu Server

When you purchase a new VPS or VDS, your server comes with default settings and becomes a target for bots as soon as it connects to the internet. To turn your server into a "fortress" and keep your projects secure, here are 5 critical security steps you should apply within the first 10 minutes.

1. Update the System

First of all, you should upgrade all packages to the latest version to patch known vulnerabilities.

sudo apt update && sudo apt upgrade -y
2. Create a New User (Stop Using Root)

Managing your server with the root user all the time is risky. It is much safer to create a new user and grant it privileges.

adduser username
usermod -aG sudo username

From now on, perform operations with this user and only use the sudo command when necessary.

3. Use SSH Key Authentication

Passwords can be guessed or cracked via brute-force attacks. Disabling password login and allowing only SSH key authentication is the most secure method.

  • Generate an SSH key on your local machine
  • Send it to the server using ssh-copy-id
PasswordAuthentication no
4. Enable Firewall (UFW)

Only allow the ports you need and block everything else to reduce your attack surface.

sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable
5. Prevent Brute-Force Attacks with Fail2Ban

Fail2Ban automatically monitors logs and blocks IP addresses that repeatedly attempt incorrect logins.

sudo apt install fail2ban -y

Even with default settings, Fail2Ban immediately starts protecting SSH logins.