← Alle Anleitungen
SSH key-based authentication + disable password login
Switch a Linux server from password SSH login to key-based authentication only -- removes the single most common attack surface (brute-forced passwords) on any internet-facing server.
Zielsystem: Ubuntu / Debian / any systemd-based LinuxSecuritySSHOffizielle Website ↗Offizielle Dokumentation ↗
Diese Anleitung basiert auf der offiziellen Dokumentation von SSH key-based authentication + disable password login, oben verlinkt — überprüfe dort immer die genauen Paket-/Versionsnamen, bevor du diese Befehle auf einem Produktionsserver ausführst, da sich Distributions- und Projektversionen mit der Zeit ändern.
1Generate a key pair on your OWN machine (not the server)
ssh-keygen -t ed25519 -C "your-name@your-computer"2Copy the public key to the server
ssh-copy-id user@your-server-ipIf ssh-copy-id isn't available, manually append the contents of ~/.ssh/id_ed25519.pub to ~/.ssh/authorized_keys on the server.
3Confirm key-based login works BEFORE disabling passwords
ssh user@your-server-ipDo not proceed until this logs you in with no password prompt -- disabling password auth before confirming this can lock you out entirely.
4Disable password authentication
sudo sed -i 's/#\?PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_configsudo systemctl restart sshd5Keep your current session open while testing a fresh one
Open a SECOND terminal and confirm a brand-new SSH connection still works before closing your original session -- your safety net if something's misconfigured.