# SSH absichern – Keys, Port ändern & Root-Login deaktivieren

SSH absichern am VPS/Root Server: Ed25519 Keys, Passwort-Login aus, Port ändern, PermitRootLogin – ohne dich auszusperren.

**Kurzantwort:** SSH absicherst du in 3 Schritten: **Ed25519-Key** einrichten → **Passwort-Login deaktivieren** → optional **Port ändern** + Fail2ban. Teste Keys immer in einem zweiten Terminal, bevor du die Session schließt.

**Wenn du hier landest:** Du willst Brute-Force-Angriffe auf Port 22 stoppen oder hast gehört, dass Passwort-Login unsicher ist.

## Schritt 1: SSH-Key erzeugen (lokal)

`ssh-keygen -t ed25519 -C "nexorahost-server"
cat ~/.ssh/id_ed25519.pub`
## Schritt 2: Key auf Server

`mkdir -p ~/.ssh && chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
# Public Key einfügen
chmod 600 ~/.ssh/authorized_keys`
Test: `ssh -i ~/.ssh/id_ed25519 root@SERVER-IP`

## Schritt 3: sshd_config härten

`nano /etc/ssh/sshd_config

PasswordAuthentication no
PermitRootLogin prohibit-password
PubkeyAuthentication yes
# Port 2222   (optional)

systemctl restart sshd`
**UFW:** Neuen Port erlauben *bevor* du den alten schließt → [Firewall Guide](/de/root-v-server/firewall-ports)

## Checkliste

- ✅ Key-Login funktioniert (zweites Terminal)
- ✅ PasswordAuthentication no
- ✅ Fail2ban aktiv → [Fail2ban](/de/root-v-server/fail2ban)
- ✅ UFW erlaubt SSH-Port

Teil der VPS-Einrichtung: [Linux VPS einrichten](/de/root-v-server/vps-einrichten)

*Produkte & Bestellung: [Root/VPS Server](https://nexorahost.com/Dedicated-server) · Verwaltung: [panel.nexorahost.de](https://panel.nexorahost.de) · [Mein Konto](https://nexorahost.com/account) · [nexorahost.com](https://nexorahost.com) (Frankfurt · 1 Tbit/s DDoS · 99,9 % Uptime)*
