SSH auf dem Raspberry Pi
Erfahre, wie du SSH auf deinem Raspberry Pi aktivierst und sicher konfigurierst, um ihn bequem aus der Ferne zu steuern – von Windows, macOS oder Linux.
Learn how to enable and securely configure SSH on your Raspberry Pi to conveniently control it remotely – from Windows, macOS, or Linux.
SSH aktivieren mit raspi-config
SSH (Secure Shell) ist auf dem Raspberry Pi standardmäßig deaktiviert. Es gibt mehrere Wege, SSH zu aktivieren. Der einfachste ist über das Konfigurationstool raspi-config:
SSH (Secure Shell) is disabled by default on the Raspberry Pi. There are several ways to enable SSH. The easiest is through the configuration tool raspi-config:
sudo raspi-configNavigiere im Menü zu:
Navigate in the menu to:
- Interface Options → SSH → Yes
Bestätige mit Enter und verlasse raspi-config. SSH ist nun aktiviert und startet automatisch beim Hochfahren.
Confirm with Enter and exit raspi-config. SSH is now enabled and will start automatically on boot.
Alternativer Weg (ohne Monitor): Erstelle eine leere Datei namens ssh (ohne Dateiendung) im Stammverzeichnis der SD-Karte (boot-Partition). Beim nächsten Start wird SSH automatisch aktiviert.
Alternative method (headless): Create an empty file called ssh (no file extension) in the root directory of the SD card (boot partition). On the next boot, SSH will be enabled automatically.
sudo systemctl enable ssh
sudo systemctl start sshStandard-Passwort ändern
Wichtig: Wenn du SSH aktivierst, solltest du unbedingt das Standard-Passwort des Benutzers „pi" ändern. Das Standard-Passwort „raspberry" ist allgemein bekannt und stellt ein erhebliches Sicherheitsrisiko dar.
Important: When you enable SSH, you should definitely change the default password of the "pi" user. The default password "raspberry" is widely known and poses a significant security risk.
passwdDu wirst aufgefordert, dein aktuelles Passwort und danach zweimal das neue Passwort einzugeben. Wähle ein starkes Passwort mit mindestens 12 Zeichen, das Groß- und Kleinbuchstaben, Zahlen und Sonderzeichen enthält.
You'll be prompted to enter your current password and then the new password twice. Choose a strong password with at least 12 characters, including uppercase and lowercase letters, numbers, and special characters.
Tipp
Neuere Versionen von Raspberry Pi OS (seit April 2022) haben keinen Standard-Benutzer „pi" mehr. Stattdessen wirst du bei der Ersteinrichtung aufgefordert, einen eigenen Benutzernamen und Passwort zu wählen.
Newer versions of Raspberry Pi OS (since April 2022) no longer have a default "pi" user. Instead, you'll be prompted to choose your own username and password during initial setup.
SSH-Key einrichten
SSH-Keys bieten eine sicherere und bequemere Authentifizierung als Passwörter. Du musst dir kein Passwort merken und bist zudem besser gegen Brute-Force-Angriffe geschützt.
SSH keys provide more secure and convenient authentication than passwords. You don't need to remember a password and you're better protected against brute-force attacks.
Schritt 3a: Erzeuge ein SSH-Schlüsselpaar auf deinem Computer (nicht auf dem Pi):
Step 3a: Generate an SSH key pair on your computer (not on the Pi):
ssh-keygen -t ed25519 -C "mein-pi-key"Drücke Enter, um den Standard-Speicherort zu akzeptieren. Du kannst optional eine Passphrase für zusätzlichen Schutz setzen.
Press Enter to accept the default location. You can optionally set a passphrase for additional protection.
Schritt 3b: Kopiere den öffentlichen Schlüssel auf den Raspberry Pi:
Step 3b: Copy the public key to the Raspberry Pi:
ssh-copy-id pi@192.168.1.100Unter Windows (PowerShell), falls ssh-copy-id nicht verfügbar ist:
On Windows (PowerShell), if ssh-copy-id is not available:
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh pi@192.168.1.100 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"Schritt 3c (optional): Deaktiviere die Passwort-Authentifizierung auf dem Pi, um nur noch SSH-Keys zu erlauben:
Step 3c (optional): Disable password authentication on the Pi to only allow SSH keys:
sudo nano /etc/ssh/sshd_configFinde und ändere folgende Zeile:
Find and change the following line:
PasswordAuthentication noStarte den SSH-Dienst anschließend neu:
Then restart the SSH service:
sudo systemctl restart sshVon Windows, macOS & Linux verbinden
Finde zunächst die IP-Adresse deines Raspberry Pi heraus (auf dem Pi ausführen):
First find your Raspberry Pi's IP address (run on the Pi):
hostname -IWindows (PowerShell oder CMD)
Windows (PowerShell or CMD)
Windows 10/11 hat einen eingebauten SSH-Client. Öffne PowerShell oder die Eingabeaufforderung:
Windows 10/11 has a built-in SSH client. Open PowerShell or Command Prompt:
ssh pi@192.168.1.100macOS & Linux (Terminal)
macOS & Linux (Terminal)
Öffne ein Terminal und verbinde dich:
Open a terminal and connect:
ssh pi@192.168.1.100Beim ersten Verbindungsaufbau wirst du gefragt, ob du dem Host vertrauen möchtest. Bestätige mit yes. Danach wirst du nach dem Passwort gefragt (es sei denn, du hast SSH-Keys eingerichtet).
On the first connection, you'll be asked if you trust the host. Confirm with yes. Then you'll be prompted for the password (unless you've set up SSH keys).
Tipp
Du kannst die Verbindung noch bequemer machen, indem du eine SSH-Konfiguration anlegst. Erstelle oder bearbeite die Datei ~/.ssh/config auf deinem Computer:
You can make the connection even more convenient by creating an SSH config. Create or edit the file ~/.ssh/config on your computer:
Host mein-pi
HostName 192.168.1.100
User pi
IdentityFile ~/.ssh/id_ed25519Danach kannst du dich einfach mit folgendem Befehl verbinden:
After that, you can simply connect with:
ssh mein-piAlternative: VNC für grafische Oberfläche
SSH eignet sich perfekt für die Steuerung über die Kommandozeile. Falls du aber Zugriff auf die grafische Benutzeroberfläche deines Pi benötigst, ist VNC (Virtual Network Computing) die richtige Wahl.
SSH is perfect for command-line control. But if you need access to the graphical user interface of your Pi, VNC (Virtual Network Computing) is the right choice.
Aktiviere VNC über raspi-config:
Enable VNC via raspi-config:
sudo raspi-configNavigiere zu:
Navigate to:
- Interface Options → VNC → Yes
Installiere dann den RealVNC Viewer auf deinem Computer (kostenlos unter https://www.realvnc.com/download/viewer/) und verbinde dich mit der IP-Adresse deines Pi.
Then install RealVNC Viewer on your computer (free at https://www.realvnc.com/download/viewer/) and connect to your Pi's IP address.
Vergleich SSH vs. VNC:
SSH vs. VNC comparison:
SSH: Nur Kommandozeile, sehr schnell, wenig Bandbreite, ideal für Serververwaltung
SSH: Command line only, very fast, low bandwidth, ideal for server management
VNC: Grafische Oberfläche, benötigt mehr Bandbreite, ideal wenn du den Desktop brauchst
VNC: Graphical interface, requires more bandwidth, ideal when you need the desktop
Tipp
Für die meisten Raspberry-Pi-Projekte reicht SSH völlig aus. VNC ist besonders nützlich, wenn du grafische Anwendungen ausführen musst oder Linux-Desktops kennenlernen möchtest. Du kannst auch beides gleichzeitig aktiviert haben.
For most Raspberry Pi projects, SSH is perfectly sufficient. VNC is particularly useful when you need to run graphical applications or want to explore Linux desktops. You can also have both enabled at the same time.