Hetzners’ cloud_servers use cloud-init for initial set up and have manage_etc_hosts enabled by default, using a template for /etc/hosts which points the hostname to the localnet IP address 127.0.1.1

To configure the hostname correctly first the automatic setup has to be disabled, then the standard Debian hostname configuration can take place.

Accoding to the cloud-init doc we need to set:

manage_etc_hosts: false

You can do this with the following ?shnippet:

sudo sed w/etc/cloud/cloud.cfg.d/10_no_manage_etc_hosts.cfg <<EOF
# $USER $(date -uIs)

manage_etc_hosts: false
EOF