Deployment GuideUpdated August 22, 2026

Practical VPS tutorial

New VPS Security Checklist

Secure a new Ubuntu VPS without locking yourself out: test SSH keys, create a sudo user, configure UFW and check effective SSH settings and Docker ports.

Before putting an app on a new VPS, sort out who can log in, which ports are public and how you'll recover from a mistake. You can do most of that in one session. Just keep a second connection available while changing access.

New VPS Security Checklist — overview

My rule here is simple: prove the new login works before removing the old one. A stricter SSH setting is no help if it locks you out.

This checklist targets a fresh Ubuntu LTS VPS, including 22.04, 24.04 and 26.04. On an existing server, inventory its services before changing firewall rules.

22.04, 24.04, 26.04Ubuntu LTS releases this checklist targets
600permission mode for authorized_keys
3001:8080Docker mapping that exposes the host port

1. Make sure you have a way back in

Open the provider's web console or recovery interface and check that you can use it. Record the server IP, SSH port and provider-level firewall rules. Take a pre-change snapshot if available; keep application backups separately.

Then install updates on the VPS:

sudo apt update
sudo apt upgrade

Review package changes. If a reboot is needed, plan it now and check console and SSH access afterward, before the server has anything important to lose.

New VPS Security Checklist — detail

2. Create a non-root administrator

The example username is deploy. Choose another if it already belongs to someone or serves another purpose.

sudo adduser deploy
sudo usermod -aG sudo deploy
sudo install -d -m 700 -o deploy -g deploy /home/deploy/.ssh
sudoedit /home/deploy/.ssh/authorized_keys

Paste your public SSH key into authorized_keys, one key per line. The private key stays on your computer. If you need to create a key pair, run ssh-keygen -t ed25519 locally first.

Set the file ownership and permissions:

sudo chown deploy:deploy /home/deploy/.ssh/authorized_keys
sudo chmod 600 /home/deploy/.ssh/authorized_keys

From a second terminal on your computer, open a new SSH connection. Replace the IP and use your actual SSH port. Once logged into the VPS, run sudo -v there:

ssh -p 22 -i ~/.ssh/id_ed25519 deploy@SERVER_IP
sudo -v

3. Allow SSH before enabling the firewall

Allow 80 and 443 as well if

this VPS serves a public website.

Leave the web rules out if

this VPS is a private worker that needs no inbound web traffic.

Check listeners with sudo ss -lntup. If SSH is on a custom port, replace 22 below before enabling UFW. Install UFW with sudo apt install ufw if it is absent.

VPS_SSH_PORT=22
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow "${VPS_SSH_PORT}/tcp"
# Add these only if this VPS serves a public website:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose

The two web rules are for a public website. A private worker may not need them. For HTTP/3, permit UDP 443 only if you actually serve it.

Test another fresh SSH connection after enabling UFW. Also check the provider firewall: traffic must pass both layers, and a rule in one does not override a block in the other.

4. Switch SSH to key-only login

Once the new account works, save this as /etc/ssh/sshd_config.d/00-vps-hardening.conf using sudoedit:

PubkeyAuthentication yes
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no

This disables password and direct root login. If you use keyboard-interactive MFA, follow that authentication policy instead of disabling it.

Now check syntax and the effective settings:

sudo /usr/sbin/sshd -t
sudo /usr/sbin/sshd -T | grep -E '^(pubkeyauthentication|permitrootlogin|passwordauthentication|kbdinteractiveauthentication) '

Look for pubkeyauthentication yes and no on the other three settings. OpenSSH usually takes the first configured value, so an earlier cloud-image snippet can change the outcome. If you use Match rules, inspect the actual login with sshd -T -C and its user/client details too. See Ubuntu's SSH configuration guidance.

Fix any mismatch before reloading:

sudo systemctl reload ssh.service

Open another key-based login as deploy. Only close the original session once the new one succeeds. This extra login test is worth the minute it takes.

5. Check Docker ports separately

If Docker is installed, inspect its published ports as well as host listeners:

sudo docker ps --format 'table {{.Names}}\t{{.Ports}}'
sudo ss -lntup

Docker's published ports can bypass UFW filtering. A mapping such as 3001:8080 normally exposes the host port; 127.0.0.1:3001:8080 limits it to localhost. A database used only by other containers usually needs no published port.

Check from another machine and include IPv6 where enabled. Don't disable Docker's firewall management as a workaround; follow its network guidance.

6. Set up maintenance you will actually notice

Review Ubuntu's automatic security updates and choose a reboot policy. If unattended upgrades aren't configured, install unattended-upgrades and run sudo dpkg-reconfigure -plow unattended-upgrades to configure them.

OS updates do not update a pinned container image. Keep a separate routine for apps, images and dependencies.

Check SSH logs when troubleshooting:

sudo journalctl -u ssh.service --since today

Before you close the terminal

CheckWhat should be true
New loginA fresh key-based session works and can use sudo.
SSH policyEffective settings match the policy you intended.
Public portsOnly required services are reachable, including over IPv6.
RecoveryYou can reach the provider console and restore application data.
MaintenanceUpdates and failed backups have an owner or an alert.

FAQ

Should I change the SSH port on a new VPS?

It can reduce log noise, but it doesn't replace key authentication and patching. If you change it, allow the new port in both firewalls and test it before closing the old connection.

Why does password login still work after I edited SSH settings?

Check snippet precedence, Match blocks and the effective configuration. Test with a genuinely new connection rather than an existing session.

Is a snapshot enough to protect a VPS?

It helps with rollback, but shares provider-account risks. Keep a separate copy of application data and keys, and test recovery.

  1. Install Docker after securing access
  2. Back up Docker apps off-server
  3. Run an agent under its own service account

Next step

Keep the deployment moving

Sources and further reading

Commands assume a fresh Ubuntu server. Replace domains, users, database names and provider-specific values before running them. VPS sizing is a practical starting point, not a guarantee: monitor the real workload and resize when CPU, memory, disk or network headroom becomes tight.

Where to run this

Affiliate links: you pay the same price as buying direct.