EpicMicrodev
Back to Blog
GUIDE · Linux & Servers

New Ubuntu VPS? 10 Things You Should Do First

Epic Microdev8 min read

A practical first-day checklist for securing and preparing a fresh Ubuntu VPS before deploying applications.

1. Before You Start

Getting access to a new VPS is only the beginning. Before deploying Docker containers, databases, websites or production applications, you should establish a clean and reasonably secure server baseline.

A fresh Ubuntu VPS often gives you direct root access and may allow password-based SSH login. Those defaults are convenient during initial provisioning, but they should not normally become your everyday production setup.

Do not disable root/password SSH authentication until SSH-key login for your new administrator has been tested successfully in a separate terminal.

You will need:

  • the public IP address of your VPS
  • the initial login details supplied by the VPS provider
  • a local Linux, macOS or compatible SSH environment
  • permission to administer the server

Throughout this guide, replace YOUR_VPS_IP with the actual public IP address of your VPS. We will also use youradmin as the example administrator username. Choose your own username in production.

2. Log In to the VPS

New Ubuntu VPS instances commonly begin with root access enabled. From your local computer, connect with SSH:

bash
ssh root@YOUR_VPS_IP

If your provider created a different initial account, use that account instead. Once connected, verify that you are operating on the intended server before making configuration changes.

bash
hostname
whoami

The important objective at this stage is simply to confirm that administrative access works.

3. Update Ubuntu

Before installing application software, update the package index and install available upgrades.

bash
apt update && apt upgrade -y

When the upgrade completes, reboot the VPS. Your SSH session will close during the reboot.

bash
reboot

Wait for the VPS to become available again and reconnect:

bash
ssh root@YOUR_VPS_IP

Keeping the operating system updated before configuring the rest of the server reduces the chance of building your production environment on top of outdated packages.

4. Create a Normal Administrator

Using root for every server task is unnecessary. Create a normal administrator account:

bash
adduser youradmin

Ubuntu will ask you to create a password and may request some optional account information. Next, allow this user to perform administrative operations through sudo:

bash
usermod -aG sudo youradmin

Your server now has root for emergency or system-level administration, and youradmin for normal server management.

Before restricting root access, make sure the new administrator account works. Do not skip that verification.

5. Configure SSH Key Authentication

SSH keys are preferable to relying on a reusable account password for remote administration. On your local computer, first check whether you already have SSH keys:

bash
ls -la ~/.ssh

If you already use a key such as id_ed25519, do not overwrite it. For a dedicated VPS administration key, create a named Ed25519 key:

bash
ssh-keygen -t ed25519 -C "vps-admin-key" -f ~/.ssh/vps_admin

This creates ~/.ssh/vps_admin as the private key and ~/.ssh/vps_admin.pub as the public key.

Never copy your private SSH key to the VPS. Only the .pub public key belongs in authorized_keys.

Display the public key and copy the complete output:

bash
cat ~/.ssh/vps_admin.pub

On the VPS, create the administrator's SSH directory and open the authorized keys file:

bash
sudo mkdir -p /home/youradmin/.ssh
sudo nano /home/youradmin/.ssh/authorized_keys

Paste the public key generated on your local computer, save the file, then configure ownership and permissions:

bash
sudo chown -R youradmin:youradmin /home/youradmin/.ssh
sudo chmod 700 /home/youradmin/.ssh
sudo chmod 600 /home/youradmin/.ssh/authorized_keys

Incorrect .ssh permissions are a common reason SSH public-key authentication fails.

6. Test Your New SSH Login

Do not close your existing administrator/root session yet. Test the new login in a second terminal first.

Open a second terminal on your local computer and test:

bash
ssh -i ~/.ssh/vps_admin youradmin@YOUR_VPS_IP

If authentication succeeds, verify the user and sudo access:

bash
whoami
sudo whoami

You should see youradmin from the first command and root from the sudo command. Only continue with SSH hardening after this test succeeds.

Optional: Simplify Your Local SSH Command

Instead of typing the IP address, username and key path every time, create a local SSH configuration.

bash
nano ~/.ssh/config
text
Host myvps
    HostName YOUR_VPS_IP
    User youradmin
    IdentityFile ~/.ssh/vps_admin
bash
chmod 600 ~/.ssh/config
ssh myvps

7. Harden SSH

Once key authentication for the administrator account has been tested successfully, you can restrict less desirable SSH login methods.

bash
sudo nano /etc/ssh/sshd_config

Make sure the relevant settings are:

text
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes

Then restart SSH:

bash
sudo systemctl restart ssh

Open another terminal and test the key login again before closing your existing session:

bash
ssh -i ~/.ssh/vps_admin youradmin@YOUR_VPS_IP

This simple habit can prevent accidentally locking yourself out of the VPS.

8. Configure the Firewall

For a typical public web server, you normally need SSH, HTTP and HTTPS. Ubuntu provides UFW as a straightforward firewall interface.

bash
sudo ufw allow OpenSSH
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable
sudo ufw status

A basic web-server configuration should allow the required management and web traffic without exposing unnecessary application or database ports.

What About PostgreSQL Port 5432?

Do not expose PostgreSQL port 5432 publicly unless your architecture explicitly requires remote database access and it is properly secured.

If your application and PostgreSQL run through Docker Compose on the same VPS, the database can normally stay inside the Docker network.

9. Install Essential Server Tools

Before moving into deployment, install a small set of useful administration tools.

bash
sudo apt update
sudo apt install -y curl wget git unzip htop nano ca-certificates gnupg lsb-release

These tools are commonly useful for downloading installation files, cloning repositories, inspecting system resources, editing server configuration, installing trusted package repositories and troubleshooting deployment problems.

You do not need to install every possible utility immediately. Keep the base server reasonably small and add software when the deployment actually requires it.

10. Run Basic Verification

Before installing Docker or deploying an application, verify the state of the VPS.

Check disk space

bash
df -h

Check memory

bash
free -m

Check the current user

bash
whoami

Check UFW

bash
sudo ufw status

Check SSH

bash
ssh -i ~/.ssh/vps_admin youradmin@YOUR_VPS_IP

At this point you should have:

  • an updated Ubuntu server
  • a non-root administrator
  • SSH key authentication
  • direct root SSH access disabled
  • password-based SSH authentication disabled
  • a firewall allowing SSH, HTTP and HTTPS
  • useful administration tools installed

That gives you a much cleaner starting point for application deployment.

Quick Checklist

Ubuntu packages updated
VPS rebooted successfully
Normal administrator account created
Administrator has sudo access
SSH key generated
Public key installed on VPS
SSH key login tested successfully
Direct root SSH login disabled
Password SSH login disabled
UFW enabled
SSH allowed
HTTP port 80 allowed
HTTPS port 443 allowed
Essential server tools installed
Disk and memory checked

11. What Should You Do Next?

A secure base operating-system configuration is only the first part of preparing a production VPS. The next step depends on what you plan to host.

For a modern Docker-based application, a typical progression is:

Secure Ubuntu
Install Docker
Create a deployment user
Clone the application
Restore environment variables
Restore the database
Start Docker Compose
Configure reverse proxy + HTTPS
Configure CI/CD
Backups and monitoring

This article intentionally stops before those deployment-specific steps. Keeping each subject separate makes it easier to follow the guide you actually need instead of working through one enormous server-setup document.

Continue the Ubuntu VPS Series

Next Article

Install Docker & Docker Compose on Ubuntu for Production

Read article

Also Coming

Deploy a Private GitHub Repository to an Ubuntu VPS

Coming Soon

Also Coming

Caddy on Ubuntu: Reverse Proxy, Domain & Automatic HTTPS

Coming Soon