Skip to content

Hetzner Cloud Server erstellen

Hetzner Cloud Console öffnen und neuen Server hinzufügen

  1. Name
    • [NAME]-server
  2. Standort
    • nur Europa
    • egal ob Nürnberg / Falkenstein / Helsinki
  3. Image
    • Debian
    • aktuellste Version (aktuell 12)
  4. Typ
    • Shared für variable Lasten
    • Dedicated für konstante Lasten
  5. IP
    • v4 + v6
  6. SSH-Keys
    • persönlichen Public Key hinzufügen
    • Key benennen nachname@[NAME]
  7. Firewall auswählen: [NAME]-firewall
  8. Cloud config
    #cloud-config
    users:
    - name: aleksandar.damjanovic
    groups: users, admin
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash
    ssh_authorized_keys:
    - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ+cYe1dd69gJWu2aQrF4tL+XKEVK7pCnl8jQMUVt/JT
    packages:
    - fail2ban
    - ufw
    - ncdu
    - bpytop
    - vim
    - git
    - haveged
    - unzip
    - dos2unix
    package_update: true
    package_upgrade: true
    runcmd:
    - printf "[sshd]\nenabled = true\nbanaction = iptables-multiport" > /etc/fail2ban/jail.local
    - systemctl enable fail2ban
    - ufw allow OpenSSH
    - ufw enable
    - sed -i -e '/^\(#\|\)PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
    - sed -i -e '/^\(#\|\)PasswordAuthentication/s/^.*$/PasswordAuthentication no/' /etc/ssh/sshd_config
    - sed -i -e '/^\(#\|\)KbdInteractiveAuthentication/s/^.*$/KbdInteractiveAuthentication no/' /etc/ssh/sshd_config
    - sed -i -e '/^\(#\|\)ChallengeResponseAuthentication/s/^.*$/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config
    - sed -i -e '/^\(#\|\)MaxAuthTries/s/^.*$/MaxAuthTries 2/' /etc/ssh/sshd_config
    - sed -i -e '/^\(#\|\)AllowTcpForwarding/s/^.*$/AllowTcpForwarding no/' /etc/ssh/sshd_config
    - sed -i -e '/^\(#\|\)X11Forwarding/s/^.*$/X11Forwarding no/' /etc/ssh/sshd_config
    - sed -i -e '/^\(#\|\)AllowAgentForwarding/s/^.*$/AllowAgentForwarding no/' /etc/ssh/sshd_config
    - sed -i -e '/^\(#\|\)AuthorizedKeysFile/s/^.*$/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
    - sed -i '$a AllowUsers aleksandar.damjanovic' /etc/ssh/sshd_config
    - reboot
  9. Server erstellen (kostenpflichtig erstellen)
    • Server wird nun im Hintergrund erstellt, das kann einen Moment dauern
  10. Root Passwort zurücksetzen
    • Root Passwort über die Server-Einstellungen zurücksetzen (Rescue -> Root-Passwort)
    • Root Passwort im Passwordmanager speichern unter Baunach [NAME] - Root