self-hosting · 8 min read

Hetzner Cloud Setup: Create and Secure Your First Server

Step-by-step Hetzner Cloud setup: create a server, connect over SSH, add a firewall, create a sudo user, enable backups, and avoid the billing surprises.

Published

Reading time

8 min

Written by

KavioWeb

Cover: Hetzner Cloud setup guide to create and secure your first server

To set up a Hetzner Cloud server, create a project in the Hetzner Console, click Add server, pick a type, location and image, add your SSH key, attach a firewall, and click Create & Buy Now. Then log in with ssh root@<your-ip>, create a sudo user, turn on a firewall, and disable root login. This guide walks through each step with the commands from Hetzner's own docs (checked November 2026), plus the billing details that surprise first-time users.

/m/b2e38b85d301d11ba514bcc9-1600.webp

What you need before you start

  • A Hetzner account and a project in the Hetzner Console (the docs call this the place where you create servers, firewalls and backups).

  • An SSH key pair on your computer. Hetzner's docs note that you can only add an SSH key in the Console when creating the server; afterwards you need a CLI or the rescue system. Add it up front.

  • A rough idea of what you will run. A static site or a small Node app needs far less than a database plus workers.

Step 1: Create the server in Hetzner Console

In your project, open Servers in the left menu and select Add server. The Creating a Server page lists the options you will see:

Option

What to pick

Why

Type

A Shared Resources plan for most small apps

Hetzner says you can change the performance later with "Rescale"

Location

The one closest to your users

Hetzner's tip for bigger projects; for small ones any location works

Image

A current Ubuntu LTS or Debian

The OS. Changing it later wipes the disk

Networking

IPv4 + IPv6 unless you know you do not need IPv4

See the cost note below

SSH key

Your public key

Cannot be added in the Console after creation

Firewalls

Attach one now (Step 3)

Blocks traffic you did not allow

Backups

Optional, decide in Step 5

20% of the server price

Name

Lowercase letters, digits and hyphens

Must be unique in the project and valid as an RFC 1123 host name

Hetzner's overview page splits the plans into Shared Resources (cost-optimized and regular performance) and Dedicated Resources (general purpose). It says shared plans suit individual applications or development environments. Current plan prices change, so check hetzner.com/cloud on the day you order rather than trusting a blog table.

When you are happy with the settings, click Create & Buy Now.

Step 2: Connect with SSH

Copy the server's IPv4 address from the Console and connect:

ssh root@<203.0.113.1> 

Replace the example address with your own. If SSH warns about host authenticity on the first connection, answering yes saves the fingerprint to ~/.ssh/known_hosts. For IPv6, Hetzner assigns each server a /64 network and the server uses the first address, so connect to the address ending in ::1 without the /64.

If you did not add an SSH key, Hetzner emails you a root password and forces you to change it at first login. Prefer a key.

Optional: add a shortcut to ~/.ssh/config on your own machine so that ssh myserver works:

Host myserver
  HostName <203.0.113.1>
  User <username>
  PreferredAuthentications publickey 

Step 3: Add a firewall

Hetzner Cloud Firewalls are free according to the firewall overview. The rules that matter:

  • Inbound rules list what may reach your server. Anything not listed is dropped, and with no rules at all, all inbound traffic is blocked.

  • Outbound rules work the same way, but with no outbound rules all outbound traffic is allowed.

  • You can apply a firewall to specific servers or to every server with a matching label.

For a web server, create a firewall under Firewalls > Create Firewall with inbound rules for TCP 22 (SSH), 80 and 443, ideally limiting port 22 to your own IP address. Then apply it to your server.

/m/9f5253c19ff4ddfaf25c7e1e-1600.webp

Hetzner's initial-setup tutorial warns to use one firewall layer, not two: either the Hetzner Cloud Firewall or UFW on the server. Mixing them can cause conflicting rules. If you prefer UFW, the tutorial's commands are:

sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status 

Add sudo ufw allow 80/tcp and sudo ufw allow 443/tcp yourself if you run a website (those two lines are standard UFW syntax, not copied from the Hetzner tutorial).

Step 4: Create a non-root user and lock down SSH

Working as root means one typo can break the server. The Initial Server Setup with Ubuntu tutorial uses this sequence:

adduser holu
usermod -aG sudo holu 

Replace holu with your username. Copy your key to the new user from your local machine:

ssh-copy-id holu@<203.0.113.1> 

Open a second terminal and confirm ssh holu@<203.0.113.1> works and sudo works. Only then edit the SSH config:

sudo nano /etc/ssh/sshd_config 

Set these lines (remove a leading # if present):

PermitRootLogin no
PasswordAuthentication no 

Only disable password authentication if your SSH key login works. Then restart SSH with sudo systemctl restart ssh (on some systems the service is called sshd: sudo systemctl restart sshd). Keep your original session open until you have confirmed a fresh login works, so a typo cannot lock you out.

Step 5: Turn on backups and take a snapshot

Hetzner has two options, described in the backups and snapshots overview:

Backups

Snapshots

Created

Automatically, daily

Manually

Kept

7 slots, oldest deleted first

Until you delete them

Survives server deletion

No, tied to the server

Yes

Cost (per the billing FAQ, as of November 2026)

20% of the server price per month

Per GB per month, for the compressed size

Neither includes attached Volumes. Hetzner recommends powering off the server for a consistent copy, though you can snapshot a running system without that guarantee. To enable backups, open Backups in the top menu, select Enable Backups, choose the server and confirm. For a database, also run your own dumps: a disk copy of a busy database may not be consistent.

A good habit: take a snapshot right after finishing Step 4. If you later break something, you can rebuild the server from it or create a duplicate. The architecture must match, so an x86 snapshot cannot create an Arm64 server.

What Hetzner Cloud actually bills for

These details come from the billing FAQ and the servers overview:

  • Hourly with a monthly cap. You pay the lower of the hourly rate times hours used or the monthly price. Usage is rounded up to a whole hour.

  • Powered-off servers still cost money. Billing continues until you delete the server. To pause for a long time, snapshot it, delete it, and recreate it later.

  • IPv4 is a separate line. Servers do not include public IPs. IPv6 Primary IPs are free; an IPv4 Primary IP costs an additional EUR 0.50 per month excluding VAT (as of November 2026). Unassigned Primary IPs are billed until you delete them.

  • Traffic. Only outgoing traffic is billed, and only beyond the amount included in your plan. Overage is billed in 100 MB blocks.

Prices are shown without VAT, so budget for tax if you are in a country where it applies.

When to move up from a basic server

Most first projects fit on a small shared plan. Look at a bigger or dedicated plan when your app is CPU-bound for long periods, when a database competes with the app for memory, or when you need predictable performance. Hetzner's docs say you can rescale a server later, so there is no need to over-buy on day one. If you are choosing between providers, our best VPS for vibe coders comparison puts Hetzner next to DigitalOcean and Vultr. Once the server is ready, you can self-host n8n on it or run Ollama with Open WebUI.

FAQ

Is Hetzner Cloud good for beginners? It is straightforward if you are comfortable with SSH, because you get a bare Linux server rather than a managed platform. Hetzner's docs cover the Console steps well, and you add security (firewall, non-root user, backups) yourself.

Can I add an SSH key after creating the server? Not in the Console. Hetzner's docs say you can still add one afterwards through a CLI, and there is a rescue-system guide for restoring access, but adding your key during creation is far easier.

Do I pay for a Hetzner server that is switched off? Yes. Per the billing FAQ, you pay for as long as the server exists, regardless of power state, because resources stay allocated. Delete it (after taking a snapshot) if you will not use it for a while.

Should I use the Hetzner Cloud Firewall or UFW? Either works, but Hetzner's tutorial recommends using only one to avoid rule conflicts. The Cloud Firewall is free, sits outside the server, and can be applied by label to many servers.

What happens if I delete a server with backups? Backups are bound to the server and are deleted with it. Snapshots are kept until you delete them, so take one before deleting.

Need help with the setup?

If you would rather have someone else harden the server, deploy your app and set up monitoring, Kavio can do it. See our services or get in touch.

Sources

  1. Creating a Server - Hetzner Docs
  2. Connecting to your Server - Hetzner Docs
  3. Firewalls overview - Hetzner Docs
  4. Billing FAQ - Hetzner Docs
  5. Servers overview - Hetzner Docs
  6. Backups/Snapshots overview - Hetzner Docs
  7. Backups/Snapshots FAQ - Hetzner Docs
  8. Initial Server Setup with Ubuntu - Hetzner Community

Next article

All articles →
Cover: security risks in AI-generated code and how to fix them

vibe-coding · 7 min read

Vibe Coding Security: 7 Risks in AI-Generated Code and Fixes

The security holes that show up most in apps built with AI coding tools: exposed keys, open databases, client-side auth, injection, hallucinated packages and unverified webhooks, with a fix for each.

Read next ↗