Datalumina

Deployment

Server setup

Create a Hostinger VPS with Docker, allow SSH only from your IP and the web port from anywhere, add a non-root user, and turn off password and root logins.

By the end of this page you have a VPS with Docker that accepts SSH only from your IP address, only with your key, and only as a normal user. Port 80 is open to everyone, because signing links go to other people.

Create an SSH key

Generate a dedicated key for this server and set a passphrase when asked.

ssh-keygen -t ed25519 -a 100 -f ~/.ssh/hostinger-contracts -C "hostinger-contracts"

Copy the public key to your clipboard:

pbcopy < ~/.ssh/hostinger-contracts.pub

Only the .pub file leaves your laptop.

Get the VPS

Open Hostinger and pick KVM 2. This project runs Postgres and builds the Next.js app on the server itself, and KVM 2 has the memory for both.

Pick the 12-month term and enter the code DAVEVPS at checkout for 10% off. The code only works on a first purchase with a yearly plan. Log in, or create an account, when the checkout asks.

Look at the renewal price before you pay. The first term is discounted, and the plan renews at a higher price.

Set up the server

After payment, log in to your Hostinger account, open Billing, then Subscriptions, and click Set up next to the VPS.

  1. Pick the data center closest to you and your clients.
  2. For the operating system, search the applications for Docker and pick the Docker template on Ubuntu 24.04.
  3. Set a strong root password and save it in your password manager.
  4. Click Add key and paste the public key. Name it hostinger-contracts.
  5. Leave the malware scanner and paid backups unchecked.

When setup finishes, click Manage VPS and copy the IPv4 address from the overview.

Open the firewall

Find your public IP address:

curl -4 https://ifconfig.me
# 203.0.113.25

In hPanel, open the VPS, then Security, then Firewall. Click Add firewall, name it contracts, open Edit, and add two rules:

ActionProtocolPortSourceSource details
AcceptTCP22Custom<YOUR_IPV4>/32
AcceptTCP80Any

Keep the drop rule that the firewall starts with. Go back to the list, turn the firewall on, and confirm Activate.

SSH is only for you. Port 80 is for everyone, because the admin page and the signing links run on it. FastAPI and Postgres get no port at all.

If your IP address changes, you are locked out of SSH until you update the rule. The hPanel Web console does not depend on this firewall, so it is your way back in.

Log in as root once

In the VPS overview, open Web console and print the server's fingerprint:

ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
# 256 SHA256:<fingerprint> root@<hostname> (ED25519)

Then connect from your laptop. Type yes only if the fingerprint matches.

ssh -o IdentitiesOnly=yes -i ~/.ssh/hostinger-contracts root@<VPS_IPV4>

Using Ghostty?

Ghostty uses a terminal name the server does not know, so editors such as nano fail with Error opening terminal: xterm-ghostty. Fix it once before you go on. Open the Ghostty config with Cmd+,, add the line below, and restart Ghostty.

shell-integration-features = ssh-env

Update and check Docker

Still as root on the server:

apt update && apt upgrade -y
docker --version
docker compose version

If docker is not found, the template did not include it. Install it with Docker's official script:

curl -fsSL https://get.docker.com | sh

Create a deploy user

You stop working as root and use a normal user called deploy. Still logged in as root, run these one block at a time.

1. Create the user. It asks for a password. Save it in your password manager, because sudo asks for it later.

adduser --gecos "" deploy

2. Give it admin rights and Docker access. sudo lets it run admin commands. docker lets it run Docker without sudo. Do not skip this line, or every Docker command later fails with permission denied.

usermod -aG sudo,docker deploy

3. Let it log in with your SSH key, so it never asks for a password.

install -d -m 700 -o deploy -g deploy /home/deploy/.ssh
install -m 600 -o deploy -g deploy /root/.ssh/authorized_keys /home/deploy/.ssh/authorized_keys

4. Check it.

id deploy
# uid=1000(deploy) gid=1000(deploy) groups=1000(deploy),27(sudo),100(users),988(docker)

The groups must include sudo and docker. If one is missing, run step 2 again. The numbers can differ.

The docker group is close to root access, so treat this user's key like a root key. Group changes only apply to new logins, which is why the next step opens a new SSH session as deploy.

Save a shortcut

The shortcut saves you from typing the IP, the user, and the key on every command. On your laptop, add this block to ~/.ssh/config (on Windows, $HOME/.ssh/config). Create the file if it does not exist.

~/.ssh/config
Host contracts-vps
  HostName <VPS_IPV4>
  User deploy
  IdentityFile ~/.ssh/hostinger-contracts
  IdentitiesOnly yes
  ServerAliveInterval 30

No shortcut?

Every command in this guide still works. Replace contracts-vps with deploy@<VPS_IPV4> and add -i ~/.ssh/hostinger-contracts right after ssh. For example, ssh contracts-vps becomes ssh -i ~/.ssh/hostinger-contracts deploy@<VPS_IPV4>.

Open a new terminal and test it, while the root session stays open:

ssh contracts-vps
whoami
# deploy

Harden SSH (optional)

The firewall already lets only your IP address reach SSH. This step adds a second lock. Nobody can log in as root or with a password, only as deploy with your SSH key. Skip it if you want to keep things short.

As deploy on the server:

sudo tee /etc/ssh/sshd_config.d/01-hardening.conf > /dev/null <<'EOF'
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
EOF
sudo sshd -t
sudo systemctl restart ssh

sshd -t prints nothing when the config is valid. The file name starts with 01 because SSH uses the first value it reads, and files in that folder load in alphabetical order. A cloud setup file such as 50-cloud-init.conf can no longer turn password login back on.

Check the active values:

sudo sshd -T | grep -E '^(permitrootlogin|passwordauthentication)'
# permitrootlogin no
# passwordauthentication no

Keep the root session open until a new ssh contracts-vps works. If something is wrong, fix it from that session or from the web console.

Check

From your laptop:

ssh contracts-vps 'whoami && docker ps'
# deploy
# CONTAINER ID   IMAGE   COMMAND   CREATED   STATUS   PORTS   NAMES

ssh -o IdentitiesOnly=yes -i ~/.ssh/hostinger-contracts root@<VPS_IPV4>
# root@<VPS_IPV4>: Permission denied (publickey).

Root can no longer log in over SSH. For admin work, connect as deploy and use sudo.

On this page