# Setting up server with Hetzner

Table of Contents

A bit about me

I got into the world of self-hosting a year and a half ago, very soon after I ditched windows to switch to Linux. Initially I used my old surface laptop as an Ubuntu server where I installed services like Immich, Paperless-ngx, and so on, but there are good reasons why one probably should not self-host websites or other services that is intended for the public, like portfolio websites or my blog in my case, and the thing that made me think about this was wanting to host a Matrix server. My goal was to give my friends and others an alternative to Discord.

Choosing a hosting

So the first step is to find a company that offers services like cloud hosting, VPS, and dedicated servers. After some research, I found that the most recommended (and relatively on the cheaper side) companies so far are:

and an additional one that I didn’t end up choosing but still very curious about and worth mentioning is Cherry Servers for bare metal cloud services.

Based on from what I checked, Hetzner seemed to be the most reasonably priced, and had good quality hardware available in addition to having a good reputation when it came to getting support. They were also relatively established for a while and apart from people complaining about the strict verification process, honestly it seemed like a solid choice.

Note about Hetzner account creation

My experience with Hetzner started off strange since after creating my account for undisclosed reasons they flagged my account as high risk. This happened even after providing a valid credit card. To verify my account, the only option was to upload my passport on their website and wait for confirmation. I thought it was rather invasive, after some searching, I found out that this is very common for initial clients of Hetzner, especially those outside of EU countries. One person on reddit posted their experience about how they emailed them about feeling uncomfortable sharing private information like a passport or ID and anecdotally Hetzner almost immediately verified their account without any problems. That’s exactly what ended up happening with me luckily. At exactly 8am Germany time I got an email verifying my account without any identification required.

Buying and setting up a server

If you check out Hetzner’s website, they always have really good deals on dedicated servers and I managed to get a pretty good one at the time. There are also VPS and cloud services available as well but I personally wanted more control and freedom over the computing resources. Once you purchase a server, Hetzner will offer you two different ways to give you acess to it and the biggest tip I have is do not use the password method, use the private key since it is much safer.

A little SSH

For those of you who do not know ssh, the idea is that you generate a private and a public key pair and the private key stays on your computer and you give the public key to various other services so that when connecting, it can be verified that it’s you.

So to use the private key method, what you want to do is go on your terminal and generate ssh-keys like this:

Terminal window
ssh-keygen

Just go with Ed25519 and the default file name for your private key and I think you’ll be fine with no passphrase. This will create two files:
/home/username/.ssh/id_ed25519 and /home/username/.ssh/id_ed25519.pub

Do not share the contents of the id_ed25519 file, that is the private key

Now just print the contents of the public key like this:

Terminal window
cat /home/username/.ssh/id_ed25519.pub

and paste it into the Hetzner prompt for the public key. After finalizing some options, you should get an email with all the information to connect via ssh to your server.

In your email, you should have the ip for the server, and the way you connect to it is through your terminal like this:

Terminal window
ssh root@[your_server_ip]

It should say

Welcome to the Hetzner Rescue System.

This Rescue System is based on Debian GNU/Linux 12 (bookworm) with a custom kernel. You can install software like you would in a normal system. ”

If you want to read more about ssh, here’s a link: https://linuxize.com/post/how-to-generate-ssh-keys-on-linux/

Installing a Linux distribution and sysadmin first steps

There’s instructions on how to install an operating system straight from Hetzner’s Rescue System here: https://docs.hetzner.com/robot/dedicated-server/operating-systems/installimage/

There’s so many different distros you can go with, but since I am used to Fedora/RHEL, I went with Alma Linux. Most of my next posts in the series will be instructions that assume the OS is Alma Linux but honestly, a lot of it can be easily translated into other operating systems without much problems.

My avatar

Thanks for reading my blog post!