Debian Server

server aufsetzen und die SSH-Schlüssel
~/.ssh/id_rsa.pub auf den Server hinterlegen oder bei der einrichtung mitgeben

Server einrichten

apt update && apt upgrade
apt install neovim htop lf tree git
tree -L 2 /etc/ssh
nvim /etc/ssh/sshd_config
    ClientAliveInterval 60
    ClientAliveCountMax 3
    PrintMotd yes
    PrintLastLog yes
    UsePAM no       (Hetzner brauch 'yes')
    PasswordAuthentication no
    AuthorizedKeysFile .ssh/authorized_keys
    # .ssh/authorized_keys2
    PubkeyAuthentication yes
    # Include /etc/ssh/sshd_config.d/**.conf
    PermitRootLogin yes
    Port 56832
    :wq
systemctl restart sshd

alle Zeilen mit einem vorangestellten '#' und 'leehrzeichen' löschen

nvim /etc/ssh/sshd_config
:g/^#/d
:g/^$/d
:wq

Hetzner Konfiguration

Include /etc/ssh/sshd_config.d/*.conf
Port 2222
PermitRootLogin prohibit-password
AuthenticationMethods publickey
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
KbdInteractiveAuthentication no
UsePAM yes
X11Forwarding no
AcceptEnv LANG LC_*
Subsystem       sftp    /usr/lib/openssh/sftp-server
PrintMotd yes
PrintLastLog yes
ClientAliveInterval 120
ClientAliveCountMax 3

fastfetch instalieren

wget https://github.com/fastfetch-cli/fastfetch/releases/download/2.33.0/fastfetch-linux-amd64.deb
dpkg -i fastfetch-linux-amd64.deb

Optional für Copy+Paste

head -n30 /etc/ssh/sshd_config

Firewall


UFW Konfigurieren

apt install ufw
ufw default deny incoming
ufw default allow outgoing
# für SSH 22 oder 2222
    ufw allow 22/tcp
# für IPv6 Verbindiungen
    ufw allow 2222/tcp from any
# für HTTPS
    ufw allow 443/tcp
# für HTTP
    ufw allow 80/tcp
sudo ufw enable
# Regel löschen
ufw delete allow 80/tcp
# bei änderungen
    ufw reload
ufw status verbose

Domain

set DNS Host Records
A und AAAA Records für . *. und www. serzen


NGINX Konfigurieren