Skip to content

Tutorials Servers Intermediate1 min read

Initial Server Setup for an Ubuntu VPS

Secure a new Ubuntu VPS: update packages, create a sudo user, set up SSH keys, disable password and root login, enable a firewall and automatic updates.

By ZSOLNET Editorial Team Updated

Key takeaways

  • Create a sudo user and log in with SSH keys.
  • Disable root and password login only after testing key login.
  • Enable UFW and unattended security updates.

Do these steps as soon as you get a new server — before installing anything else.

1. Log in and update

ssh root@203.0.113.10
apt update && apt upgrade -y

2. Create a regular user

adduser deploy
usermod -aG sudo deploy

3. Set up SSH key login

On your computer, create a key if you don’t have one, then copy it to the server:

ssh-keygen -t ed25519
ssh-copy-id deploy@203.0.113.10

Log in as the new user in a new terminal to confirm it works before continuing.

4. Disable password and root login

Edit /etc/ssh/sshd_config (or add a file in /etc/ssh/sshd_config.d/):

PermitRootLogin no
PasswordAuthentication no

Then reload SSH:

sudo systemctl reload ssh

5. Enable a firewall

sudo ufw allow OpenSSH
sudo ufw enable

6. Turn on automatic security updates

sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades

7. Set the hostname and time zone

sudo hostnamectl set-hostname web1
sudo timedatectl set-timezone Asia/Dubai

Your server is now ready for a web server, database or application.

Share X LinkedIn Facebook

Log in to your account

Manage your domains, hosting and invoices in one place.

Secure connection straight to the ZSOLNET client area.

No account yet?