In one of my earlier posts I showed you how to setup Debian on a VPS from Hetzner. This time, I will show you how to setup a VPS based on CentOS 7. Nevertheless, those settings are appliable to any VPS, not just to the ones from Hetzner.

Since my last endeavor with Hetzner, many things have changed. They started offering Cloud based virtual computing, a better option than the old vServer options. Thus, you have a highly configurable, modern and quick platform. Below you have an overview of the Hetzner Cloud offer.


In this post, I will walk you through the setup process of a Cloud based virtual server at Hetzner.

Install CentOS

When I say install CentOS I really mean choose CentOS image when you setup your first Cloud Project on Hetzner.


After selecting your CentOS instance, it only takes about 15 seconds for the Project to be ready. You will receive an e-mail with the login credentials, and you are ready to go.

Setting up CentOS

1 Setup the keyboard configuration

As Hetzner is a German based company, you will have your keyboard map set up to German by default. Thus, in order to use your preffered layout, you will need to change the settings first.

I will change it from de to us, my keyboard layout. For this, I will use the command:

localectl set-keymap us

To check if your settings have been changed, use the command:


This will give you an output close to this:

 System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us

2 Initial system update and firewall configuration

After setting up your keyboard layout, first thing that I advice you to do is to do an system update, with the command:

sudo yum update

The second most important step for me is to install and configure the firewall. By defalt, CentOS 7 still uses the old iptables firewall, but can use the newer Firewalld, which is easier to configure if you start to know it.

To install it, use the command:

sudo yum install firewalld
sudo systemctl start firewalld

The second command from above is to start the firewalld service.

3 Install vim text editor

Neither vim nor nano are installed on CentOS by default, thus you will have to install them. I like vim, so I will just install it using the command:

sudo yum install vim

4 Add a new user

Next step is to add a new user that you will use instead of root. For this, use the following commands:

adduser new_user
passwd new_user

And now, add your new user to the wheel group, so that you can use sudo with it.

gpasswd -a new_user wheel

5 Generate a SSH key to login with

On your local system use the command ssh-keygen to generate a SSH key, then you will have to upload it to the server. You can do that with the command:

ssh-copy-id user@server_ip_address

Where the user is the name of your user to login to the server, and the server_ip_address is your server’s public IP address. This command will securely copy the public ssh key to the server.

6 Configure the firewall for SSH

Now you will need to configure your firewall for SSH using the command:

sudo firewall-cmd --permanent --add-service=ssh

If you have changed the SSH port from 22 to another, you will have to add it specificaly to the firewall using the command:

sudo firewall-cmd --permanent --remove-service=ssh
sudo firewall-cmd --permanent --add-port=XXXX/tcp

Where XXXX is the new port number for SSH.

7 Add optional repositories

As by default CentOS has a limited repository, you will need to install some extra repos like EPEL repository for example. To do this, use the command:

sudo yum install epel-release

Further configurations

Further on, depending on what you plan to do with your new server, you could install the entire LAMP stack, or just Apache and Jekyll, or maybe Docker, as we showed in an earlier post. Nevertheless, the possibilities are endless now that we have basically configured CentOS.

The topic of installing LAMP on CentOS will be covered in another post, as well as setting up and working with Jekyll.

Enjoy! Keep learning!