{"id":2099,"date":"2026-02-26T06:45:24","date_gmt":"2026-02-26T06:45:24","guid":{"rendered":"https:\/\/ghanim-solution.de\/?p=2099"},"modified":"2026-02-26T07:31:38","modified_gmt":"2026-02-26T07:31:38","slug":"authentifizierung-2fa-fur-debian-uber-ssh-einrichten-google-authenticator-totp","status":"publish","type":"post","link":"https:\/\/ghanim-solution.de\/index.php\/2026\/02\/26\/authentifizierung-2fa-fur-debian-uber-ssh-einrichten-google-authenticator-totp\/","title":{"rendered":"Authentifizierung (2FA) f\u00fcr Debian \u00fcber SSH einrichten (Google Authenticator \/ TOTP)"},"content":{"rendered":"\n<p>Wenn dein <strong>Debian-Server<\/strong> (oder <strong>Raspberry Pi OS<\/strong>) per SSH erreichbar ist, solltest du ihn unbedingt zus\u00e4tzlich absichern.<br>Mit <strong>2-Faktor-Authentifizierung (2FA)<\/strong> sch\u00fctzt du dein System selbst dann, wenn jemand dein Passwort kennt.<\/p>\n\n\n\n<p>F\u00fcr Debian nutzt man daf\u00fcr meist den <strong>Google Authenticator<\/strong>.<br>Wichtig: Du brauchst <strong>kein Google-Konto<\/strong> \u2013 es handelt sich um den offenen Standard <strong>TOTP (Time-based One-Time Password)<\/strong>.<\/p>\n\n\n\n<p>Hier kommt die vollst\u00e4ndige Schritt-f\u00fcr-Schritt-Anleitung zur Absicherung von SSH mit 2FA.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 Voraussetzungen<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Debian Server oder Raspberry Pi OS<\/li>\n\n\n\n<li>SSH-Zugang funktioniert bereits<\/li>\n\n\n\n<li>Ein Smartphone mit einer TOTP-App (z. B. Google Authenticator, Authy oder Bitwarden)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">1\ufe0f\u20e3 Ben\u00f6tigtes PAM-Modul installieren<\/h2>\n\n\n\n<p>Zuerst installierst du das Google-Authenticator-PAM-Modul:<br><\/p>\n\n\n\n<pre><code class=\"language-bash\"> sudo apt update sudo apt install libpam-google-authenticator <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2\ufe0f\u20e3 2FA f\u00fcr deinen Benutzer einrichten<\/h2>\n\n\n\n<p>\u26a0 Wichtig:<br>F\u00fchre diesen Schritt <strong>mit dem Benutzer aus, mit dem du dich sp\u00e4ter per SSH einloggst<\/strong> \u2013 NICHT als root.<\/p>\n\n\n\n<p>Starte das Setup:<\/p>\n\n\n\n<pre><code class=\"language-bash\"> google-authenticator <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Beantworte die Fragen wie folgt:<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Frage<\/th><th>Antwort<\/th><th>Empfehlung<\/th><\/tr><\/thead><tbody><tr><td>Do you want authentication tokens to be time-based?<\/td><td><code>y<\/code><\/td><td>Standard TOTP<\/td><\/tr><tr><td>QR-Code anzeigen?<\/td><td>Scannen<\/td><td>Mit deiner Authenticator-App<\/td><\/tr><tr><td>Emergency scratch codes<\/td><td>Aufschreiben!<\/td><td>Backup bei Handyverlust<\/td><\/tr><tr><td>Update your .google_authenticator file?<\/td><td><code>y<\/code><\/td><td>Speichert Konfiguration<\/td><\/tr><tr><td>Disallow multiple uses of the same token?<\/td><td><code>y<\/code><\/td><td>Schutz vor Replay<\/td><\/tr><tr><td>Increase time window?<\/td><td><code>n<\/code><\/td><td>Nur bei falscher Systemzeit<\/td><\/tr><tr><td>Enable rate-limiting?<\/td><td><code>y<\/code><\/td><td>Schutz vor Brute-Force<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Nach Abschluss wird die Datei <code>.google_authenticator<\/code> im Home-Verzeichnis gespeichert.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3\ufe0f\u20e3 PAM f\u00fcr SSH aktivieren<\/h2>\n\n\n\n<p>Jetzt bringen wir SSH bei, 2FA zu verwenden.<\/p>\n\n\n\n<p>\u00d6ffne die PAM-Konfiguration:<\/p>\n\n\n\n<pre><code class=\"language-bash\"> sudo nano \/etc\/pam.d\/sshd <\/code><\/pre>\n\n\n\n<p>F\u00fcge ganz oben (oder direkt unter <code>@include common-auth<\/code>) folgende Zeile ein:<\/p>\n\n\n\n<pre><code class=\"language-bash\"> auth required pam_google_authenticator.so <\/code><\/pre>\n\n\n\n<p>Datei speichern.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4\ufe0f\u20e3 SSH-Daemon konfigurieren<\/h2>\n\n\n\n<p>\u00d6ffne die SSH-Konfigurationsdatei:<\/p>\n\n\n\n<pre><code class=\"language-bash\"> sudo nano \/etc\/ssh\/sshd_config <\/code><\/pre>\n\n\n\n<p>Suche folgende Eintr\u00e4ge und stelle sicher, dass sie so gesetzt sind:<\/p>\n\n\n\n<pre><code class=\"language-plaintext\"> UsePAM yes KbdInteractiveAuthentication yes <\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote has-large-font-size is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-large-font-size\">Hinweis: In \u00e4lteren Debian-Versionen hei\u00dft die Option <code>ChallengeResponseAuthentication<\/code>.<\/p>\n<\/blockquote>\n\n\n\n<p>Optional \u2013 wenn du Passwort + 2FA erzwingen willst, stelle sicher:<\/p>\n\n\n\n<pre><code class=\"language-plaintext\"> PasswordAuthentication yes <\/code><\/pre>\n\n\n\n<p>Speichern und schlie\u00dfen.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5\ufe0f\u20e3 SSH-Dienst neu starten<\/h2>\n\n\n\n<pre><code class=\"language-bash\"> sudo systemctl restart ssh <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u26a0\ufe0f WICHTIG: Sicherheitstest durchf\u00fchren<\/h2>\n\n\n\n<p><strong>Schlie\u00dfe deine aktuelle SSH-Verbindung NICHT!<\/strong><\/p>\n\n\n\n<p>Stattdessen:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u00d6ffne ein neues Terminal-Fenster<\/li>\n\n\n\n<li>Verbinde dich erneut per SSH<\/li>\n\n\n\n<li>Teste den Login<\/li>\n<\/ol>\n\n\n\n<p>Wenn alles korrekt funktioniert:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Passwort eingeben<\/li>\n\n\n\n<li>Danach erscheint: <code>Verification code:<\/code><\/li>\n\n\n\n<li>6-stelligen Code aus deiner Authenticator-App eingeben<\/li>\n<\/ol>\n\n\n\n<p>Erst wenn das erfolgreich funktioniert, kannst du das alte Terminal schlie\u00dfen.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd10 Optional: Noch sicherer machen (Empfohlen)<\/h2>\n\n\n\n<p>F\u00fcr maximale Sicherheit kannst du zus\u00e4tzlich:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Nur SSH-Key + 2FA erlauben<\/h3>\n\n\n\n<p>In <code>\/etc\/ssh\/sshd_config<\/code>:<\/p>\n\n\n\n<pre><code class=\"language-plaintext\"> PasswordAuthentication no AuthenticationMethods publickey,keyboard-interactive <\/code><\/pre>\n\n\n\n<p>Dann neu starten:<\/p>\n\n\n\n<pre><code class=\"language-bash\"> sudo systemctl restart ssh <\/code><\/pre>\n\n\n\n<p>Damit brauchst du:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SSH-Key<\/li>\n\n\n\n<li>UND 2FA-Code<\/li>\n<\/ul>\n\n\n\n<p>Das ist extrem sicher.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udee1 Fehlerbehebung<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">2FA wird nicht abgefragt?<\/h3>\n\n\n\n<p>Pr\u00fcfe:<\/p>\n\n\n\n<pre><code class=\"language-bash\"> sudo sshd -t <\/code><\/pre>\n\n\n\n<p>Wenn keine Fehler angezeigt werden, ist die Konfiguration syntaktisch korrekt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udfaf Fazit<\/h2>\n\n\n\n<p>Mit wenigen Schritten hast du:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Brute-Force-Angriffe stark reduziert<\/li>\n\n\n\n<li>Passwortdiebstahl abgesichert<\/li>\n\n\n\n<li>Deinen Debian-Server professionell geh\u00e4rtet<\/li>\n<\/ul>\n\n\n\n<p>2FA \u00fcber SSH ist heute ein Sicherheitsstandard \u2013 besonders bei \u00f6ffentlich erreichbaren Servern.<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wenn dein Debian-Server (oder Raspberry Pi OS) per SSH erreichbar ist, solltest du ihn unbedingt zus\u00e4tzlich absichern.Mit 2-Faktor-Authentifizierung (2FA) sch\u00fctzt du dein System selbst dann, wenn jemand dein Passwort kennt. F\u00fcr Debian nutzt man daf\u00fcr meist den Google Authenticator.Wichtig: Du brauchst kein Google-Konto \u2013 es handelt sich um den offenen Standard TOTP (Time-based One-Time Password). [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2102,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2099","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/posts\/2099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/comments?post=2099"}],"version-history":[{"count":1,"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/posts\/2099\/revisions"}],"predecessor-version":[{"id":2100,"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/posts\/2099\/revisions\/2100"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/media\/2102"}],"wp:attachment":[{"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/media?parent=2099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/categories?post=2099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ghanim-solution.de\/index.php\/wp-json\/wp\/v2\/tags?post=2099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}