{"id":53063,"date":"2024-10-09T07:59:16","date_gmt":"2024-10-08T23:59:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/53063\/"},"modified":"2024-11-14T10:36:15","modified_gmt":"2024-11-14T02:36:15","slug":"%e5%9c%a8-ubuntu-%e5%92%8c-debian-%e4%b8%8a%e5%95%9f%e7%94%a8%e9%9b%99%e5%9b%a0%e5%ad%90%e8%ba%ab%e4%bb%bd%e9%a9%97%e8%ad%89%e7%9a%84%e4%b8%89%e7%a8%ae%e5%82%99%e9%81%b8%e6%96%b9%e6%a1%88-2","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/53063\/","title":{"rendered":"\u5728 Ubuntu \u548c Debian \u4e0a\u555f\u7528\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\u7684\u4e09\u7a2e\u5099\u9078\u65b9\u6848"},"content":{"rendered":"<h1 id=\"%e5%9c%a8-ubuntu-%e5%92%8c-debian-%e4%b8%8a%e5%95%9f%e7%94%a8%e9%9b%99%e5%9b%a0%e5%ad%90%e8%ba%ab%e4%bb%bd%e9%a9%97%e8%ad%89%e7%9a%84%e4%b8%89%e7%a8%ae%e5%82%99%e9%81%b8%e6%96%b9%e6%a1%88-wpGGKNXVfg\">\u5728 Ubuntu \u548c Debian \u4e0a\u555f\u7528\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\u7684\u4e09\u7a2e\u5099\u9078\u65b9\u6848<\/h1>\n<p>\u96a8\u8457\u7db2\u7d61\u5b89\u5168\u5a01\u8105\u7684\u589e\u52a0\uff0c\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\uff082FA\uff09\u5df2\u6210\u70ba\u4fdd\u8b77\u7cfb\u7d71\u548c\u6578\u64da\u7684\u91cd\u8981\u63aa\u65bd\u3002\u5c0d\u65bc\u4f7f\u7528 Ubuntu \u548c Debian \u7684\u7528\u6236\u4f86\u8aaa\uff0c\u555f\u7528\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u5b89\u5168\u6027\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u4e09\u7a2e\u5728\u9019\u4e9b\u64cd\u4f5c\u7cfb\u7d71\u4e0a\u555f\u7528\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\u7684\u5099\u9078\u65b9\u6848\u3002<\/p>\n<h2 id=\"1-google-authenticator-wpGGKNXVfg\">1. Google Authenticator<\/h2>\n<p>Google Authenticator \u662f\u4e00\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\u5de5\u5177\uff0c\u652f\u6301 TOTP\uff08\u57fa\u65bc\u6642\u9593\u7684\u4e00\u6b21\u6027\u5bc6\u78bc\uff09\u548c HOTP\uff08\u57fa\u65bc\u8a08\u6578\u7684\u4e00\u6b21\u6027\u5bc6\u78bc\uff09\u5354\u8b70\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728 Ubuntu \u548c Debian \u4e0a\u5b89\u88dd\u548c\u914d\u7f6e Google Authenticator \u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"%e5%ae%89%e8%a3%9d-google-authenticator-wpGGKNXVfg\">\u5b89\u88dd Google Authenticator<\/h3>\n<pre><code>sudo apt-get update\nsudo apt-get install libpam-google-authenticator<\/code><\/pre>\n<h3 id=\"%e9%85%8d%e7%bd%ae-google-authenticator-wpGGKNXVfg\">\u914d\u7f6e Google Authenticator<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u5bc6\u9470\uff1a<\/p>\n<pre><code>google-authenticator<\/code><\/pre>\n<p>\u9019\u5c07\u63d0\u793a\u60a8\u56de\u7b54\u5e7e\u500b\u554f\u984c\uff0c\u4e26\u751f\u6210\u4e00\u500b QR \u78bc\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Google Authenticator \u61c9\u7528\u6383\u63cf\u3002\u8acb\u52d9\u5fc5\u8a18\u4e0b\u5099\u7528\u5bc6\u78bc\uff0c\u4ee5\u9632\u60a8\u7121\u6cd5\u8a2a\u554f\u61c9\u7528\u3002<\/p>\n<h3 id=\"%e6%9b%b4%e6%96%b0-pam-%e9%85%8d%e7%bd%ae-wpGGKNXVfg\">\u66f4\u65b0 PAM \u914d\u7f6e<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u66f4\u65b0 PAM\uff08\u53ef\u63d2\u62d4\u8eab\u4efd\u9a57\u8b49\u6a21\u584a\uff09\u914d\u7f6e\u3002\u7de8\u8f2f \/etc\/pam.d\/sshd \u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code>auth required pam_google_authenticator.so<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u7de8\u8f2f \/etc\/ssh\/sshd_config \u6587\u4ef6\uff0c\u78ba\u4fdd\u4ee5\u4e0b\u884c\u88ab\u8a2d\u7f6e\u70ba yes\uff1a<\/p>\n<pre><code>ChallengeResponseAuthentication yes<\/code><\/pre>\n<p>\u6700\u5f8c\uff0c\u91cd\u555f SSH \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart sshd<\/code><\/pre>\n<h2 id=\"2-duo-security-wpGGKNXVfg\">2. Duo Security<\/h2>\n<p>Duo Security \u662f\u53e6\u4e00\u500b\u6d41\u884c\u7684\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\u89e3\u6c7a\u65b9\u6848\uff0c\u63d0\u4f9b\u7c21\u55ae\u7684\u96c6\u6210\u548c\u591a\u7a2e\u8eab\u4efd\u9a57\u8b49\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728 Ubuntu \u548c Debian \u4e0a\u8a2d\u7f6e Duo Security \u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"%e8%a8%bb%e5%86%8a-duo-security-wpGGKNXVfg\">\u8a3b\u518a Duo Security<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728 Duo Security \u7684\u7db2\u7ad9\u4e0a\u8a3b\u518a\u4e00\u500b\u5e33\u6236\uff0c\u4e26\u5275\u5efa\u4e00\u500b\u61c9\u7528\u7a0b\u5e8f\u4ee5\u7372\u53d6\u96c6\u6210\u5bc6\u9470\u3001\u79d8\u5bc6\u5bc6\u9470\u548c API \u4e3b\u6a5f\u540d\u3002<\/p>\n<h3 id=\"%e5%ae%89%e8%a3%9d-duo-pam-%e6%a8%a1%e5%a1%8a-wpGGKNXVfg\">\u5b89\u88dd Duo PAM \u6a21\u584a<\/h3>\n<pre><code>sudo apt-get install duo-unix<\/code><\/pre>\n<h3 id=\"%e9%85%8d%e7%bd%ae-duo-pam-wpGGKNXVfg\">\u914d\u7f6e Duo PAM<\/h3>\n<p>\u7de8\u8f2f \/etc\/duo\/pam_duo.conf \u6587\u4ef6\uff0c\u586b\u5165\u60a8\u5f9e Duo Security \u7372\u5f97\u7684\u5bc6\u9470\u548c\u4e3b\u6a5f\u540d\u3002\u7136\u5f8c\uff0c\u7de8\u8f2f \/etc\/pam.d\/sshd \u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code>auth required pam_duo.so<\/code><\/pre>\n<p>\u540c\u6a23\uff0c\u78ba\u4fdd\u5728 \/etc\/ssh\/sshd_config \u6587\u4ef6\u4e2d\u555f\u7528 ChallengeResponseAuthentication\uff0c\u7136\u5f8c\u91cd\u555f SSH \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart sshd<\/code><\/pre>\n<h2 id=\"3-yubikey-wpGGKNXVfg\">3. YubiKey<\/h2>\n<p>YubiKey \u662f\u4e00\u7a2e\u786c\u9ad4\u5b89\u5168\u5bc6\u9470\uff0c\u63d0\u4f9b\u5f37\u5927\u7684\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\u3002\u4f7f\u7528 YubiKey\uff0c\u60a8\u53ef\u4ee5\u751f\u6210\u4e00\u6b21\u6027\u5bc6\u78bc\u6216\u4f7f\u7528 U2F\uff08\u901a\u7528\u4e8c\u6b21\u8eab\u4efd\u9a57\u8b49\uff09\u9032\u884c\u8eab\u4efd\u9a57\u8b49\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u5728 Ubuntu \u548c Debian \u4e0a\u8a2d\u7f6e YubiKey \u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"%e5%ae%89%e8%a3%9d%e5%bf%85%e8%a6%81%e7%9a%84%e8%bb%9f%e4%bb%b6-wpGGKNXVfg\">\u5b89\u88dd\u5fc5\u8981\u7684\u8edf\u4ef6<\/h3>\n<pre><code>sudo apt-get install libpam-yubico<\/code><\/pre>\n<h3 id=\"%e9%85%8d%e7%bd%ae-yubikey-wpGGKNXVfg\">\u914d\u7f6e YubiKey<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728 Yubico \u7684\u7db2\u7ad9\u4e0a\u8a3b\u518a\u4e26\u7372\u53d6\u60a8\u7684\u5ba2\u6236 ID \u548c\u5bc6\u9470\u3002\u7136\u5f8c\uff0c\u7de8\u8f2f \/etc\/yubico\/yubikeys.conf \u6587\u4ef6\uff0c\u6dfb\u52a0\u60a8\u7684 YubiKey \u4fe1\u606f\u3002<\/p>\n<h3 id=\"%e6%9b%b4%e6%96%b0-pam-%e9%85%8d%e7%bd%ae-wpGGKNXVfg\">\u66f4\u65b0 PAM \u914d\u7f6e<\/h3>\n<p>\u7de8\u8f2f \/etc\/pam.d\/sshd \u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code>auth required pam_yubico.so id=YOUR_CLIENT_ID key=YOUR_SECRET_KEY<\/code><\/pre>\n<p>\u540c\u6a23\uff0c\u78ba\u4fdd\u5728 \/etc\/ssh\/sshd_config \u6587\u4ef6\u4e2d\u555f\u7528 ChallengeResponseAuthentication\uff0c\u7136\u5f8c\u91cd\u555f SSH \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart sshd<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-wpGGKNXVfg\">\u7e3d\u7d50<\/h2>\n<p>\u5728 Ubuntu \u548c Debian \u4e0a\u555f\u7528\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\u662f\u63d0\u9ad8\u7cfb\u7d71\u5b89\u5168\u6027\u7684\u6709\u6548\u65b9\u6cd5\u3002\u7121\u8ad6\u60a8\u9078\u64c7 Google Authenticator\u3001Duo Security \u9084\u662f YubiKey\uff0c\u9019\u4e9b\u65b9\u6848\u90fd\u80fd\u70ba\u60a8\u7684\u7cfb\u7d71\u63d0\u4f9b\u984d\u5916\u7684\u4fdd\u8b77\u3002\u96a8\u8457\u7db2\u7d61\u5b89\u5168\u5a01\u8105\u7684\u65e5\u76ca\u589e\u52a0\uff0c\u5be6\u65bd\u9019\u4e9b\u63aa\u65bd\u5c07\u6709\u52a9\u65bc\u4fdd\u8b77\u60a8\u7684\u6578\u64da\u548c\u8cc7\u6e90\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u591a\u6709\u95dc <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u7684\u4fe1\u606f\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u5728 Ubuntu \u548c Debian \u4e0a\u555f\u7528\u96d9\u56e0\u5b50\u8eab\u4efd\u9a57\u8b49\u7684\u4e09\u7a2e\u5099\u9078\u65b9\u6848\uff0c\u589e\u5f37\u7cfb\u7d71\u5b89\u5168\u6027\uff0c\u4fdd\u8b77\u60a8\u7684\u6578\u64da\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-53063","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53063","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=53063"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53063\/revisions"}],"predecessor-version":[{"id":53064,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53063\/revisions\/53064"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=53063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=53063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=53063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}