{"id":1211,"date":"2019-04-03T05:02:23","date_gmt":"2019-04-03T05:02:23","guid":{"rendered":"http:\/\/www.ipcpu.com\/?p=1211"},"modified":"2019-05-12T05:03:53","modified_gmt":"2019-05-12T05:03:53","slug":"openvpn-googleauthenticator","status":"publish","type":"post","link":"https:\/\/c.ipcpu.com\/2019\/04\/openvpn-googleauthenticator\/","title":{"rendered":"OpenVPN\u542f\u7528LDAP+GoogleAuthenticator\u8ba4\u8bc1"},"content":{"rendered":"

OpenVPN\u542f\u7528LDAP+GoogleAuthenticator\u8ba4\u8bc1.md.md<\/p>\n

\u4e00\u3001\u6982\u8ff0<\/h2>\n

\u5728\u4e0a\u4e00\u7bc7\u6587\u7ae0\u5f53\u4e2d\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86openVPN+LDAP\u7684\u8ba4\u8bc1\u65b9\u5f0f\u3002<\/p>\n

\u4f46\u5f80\u5f80\u5728\u4f01\u4e1a\u73af\u5883\u4e2d\uff0cLDAP\u7528\u6237\u540d\u5bc6\u7801\u53ef\u4ee5\u8bf4\u662f\u4e00\u53f7\u8d70\u5929\u4e0b\uff0c\u4e00\u65e6\u51fa\u73b0\u7528\u6237\u540d\u5bc6\u7801\u6cc4\u9732(\u7c97\u5fc3\u7a0b\u5e8f\u5458\u4f20\u5230github)\uff0c\u90a3\u635f\u5931\u662f\u5de8\u5927\u7684\uff0c\u56e0\u6b64\u52a0\u4e0a\u53cc\u56e0\u5b50\u8ba4\u8bc1\uff0c\u4e5f\u662f\u52a0\u4e0a\u4e86\u4e00\u5c42\u4fdd\u9669\u3002\u8fd9\u91cc\u6211\u4eec\u7684\u53cc\u56e0\u5b50\u8ba4\u8bc1\u662f\u901a\u8fc7GoogleAuthenticator\u5b9e\u73b0\u7684\uff0c\u56e0\u4e3a\u4ed6\u7684\u539f\u7406\u6bd4\u8f83\u7b80\u5355\uff0c\u5728\u4e1a\u5185\u4e5f\u5f88\u901a\u7528\u3002<\/p>\n

\u4e8c\u3001\u5b89\u88c5<\/h2>\n

\u8981\u5b9e\u73b0LDAP+GoogleAuthenticator\u8ba4\u8bc1\uff0copenvpn\u9700\u8981\u5b89\u88c5\u4e24\u4e2a\u63d2\u4ef6<\/p>\n

https:\/\/github.com\/threerings\/openvpn-auth-ldap<\/a>
\n
https:\/\/github.com\/evgeny-gridasov\/openvpn-otp<\/a><\/p>\n

\u7b2c\u4e00\u4e2a\u5b9e\u73b0LDAP\u767b\u9646\uff0c\u7b2c\u4e8c\u4e2a\u5b9e\u73b0OTP\u3002\u7531\u4e8e\u4e24\u4e2a\u63d2\u4ef6\u5148\u540e\u987a\u5e8f\u9700\u8981\u517c\u5bb9\uff0c\u5fc5\u987b\u4f7f\u7528\u6700\u65b0\u7248\u672c\u3002<\/p>\n

\n
#@\u5b89\u88c5LDAP\u63d2\u4ef6\r\ngit clone https:\/\/github.com\/threerings\/openvpn-auth-ldap\r\ncd openvpn-auth-ldap\r\n#@\u5b89\u88c5\u4f9d\u8d56\r\nyum install re2c libtool openldap openldap-devel openvpn openvpn-devel gcc-objc -y\r\n#@\u4e0b\u8f7d\u5b89\u88c5\u5305\u89e3\u538b\uff0c\u5f00\u59cb\u7f16\u8bd1\r\n.\/regen.sh \r\n.\/configure --with-openldap=\/usr\/ --with-openvpn=\/usr\/ CFLAGS=\"-fPIC\" OBJCFLAGS=\"-std=gnu11\"\r\nmake \r\nmake install\r\n#@\u5b89\u88c5OTP\u63d2\u4ef6\r\ngit clone https:\/\/github.com\/evgeny-gridasov\/openvpn-otp\r\ncd openvpn-otp\r\nyum install autoconf automake libtool* -y\r\n.\/autogen.sh\r\n.\/configure \r\nmake\r\nmake install<\/code><\/pre>\n<\/div>\n

\u5b89\u88c5\u5b8c\u6210\u540e\u53ef\u4ee5\u627e\u5230\u8fd9\u4e24\u4e2a\u63d2\u4ef6\u3002(.so\u6a21\u5757\u53ef\u4ee5\u4efb\u610f\u62f7\u8d1d\u5230\u5176\u4ed6\u76ee\u5f55\u4f7f\u7528\u7684)<\/p>\n

\n
\/usr\/local\/lib\/openvpn-auth-ldap.so\r\n\/usr\/local\/lib\/openvpn\/openvpn-otp.so<\/code><\/pre>\n<\/div>\n

\u4e09\u3001\u670d\u52a1\u5668\u7aef\u914d\u7f6e<\/h2>\n

\u6709\u4e86\u63d2\u4ef6\u4ee5\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u4fee\u6539\u670d\u52a1\u5668\u7aef\u914d\u7f6e\u4e86\uff0c\u4e3b\u8981\u7528\u5230\u4e86\u4e09\u4e2a\u914d\u7f6e\u6587\u4ef6server.conf \u4e3b\u914d\u7f6e\u6587\u4ef6\uff0cldap.conf\u548cLDAP\u8fde\u63a5\u914d\u7f6e\u6587\u4ef6\uff0cOTP\u914d\u7f6e\u6587\u4ef6otp-secrets\u3002
\n\u5148\u770b\u4e0bserver.conf<\/p>\n

\n
port 1194\r\nproto tcp\r\ndev tun\r\n\r\nca \/etc\/openvpn\/easy-rsa\/pki\/ca.crt\r\ncert \/etc\/openvpn\/easy-rsa\/pki\/issued\/server.crt\r\nkey \/etc\/openvpn\/easy-rsa\/pki\/private\/server.key\r\ndh \/etc\/openvpn\/easy-rsa\/pki\/dh.pem\r\n\r\ntopology net30\r\nserver 211.81.175.0 255.255.255.0\r\n\r\nifconfig-pool-persist ipp.txt\r\n\r\npush \"route 211.168.10.0 255.255.255.0\"\r\npush \"route 211.168.20.0 255.255.255.0\"\r\nclient-config-dir ccd\r\n\r\nclient-to-client\r\nkeepalive 10 120\r\n\r\ncipher AES-256-CBC\r\ncomp-lzo\r\nmax-clients 1000\r\n\r\npersist-key\r\npersist-tun\r\nstatus openvpn-status.log\r\nverb 3\r\n\r\ncrl-verify \/etc\/openvpn\/easy-rsa\/pki\/crl.pem\r\nplugin \/usr\/local\/lib\/openvpn-auth-ldap.so \"\/etc\/openvpn\/auth\/ldap.conf\" \r\nplugin \/usr\/local\/lib\/openvpn\/openvpn-otp.so \"password_is_cr=1 otp_secrets=\/etc\/openvpn\/auth\/otp-secrets\"\r\n\r\n#\u8c03\u7528\u9a8c\u8bc1\u811a\u672c\uff0c\u751f\u6210OTP\u5171\u4eab\u5bc6\u94a5\r\nscript-security 2\r\nauth-user-pass-verify \/etc\/openvpn\/scripts\/check_cn_on_connect.sh via-env\r\n\r\nclient-cert-not-required\r\n#@reneg-sec\u670d\u52a1\u5668\u7aef\u4f1a\u5b9a\u671f\u68c0\u67e5\u8ba4\u8bc1\u60c5\u51b5\uff0c\u9ed8\u8ba43600\u79d2\u4e00\u5c0f\u65f6\uff0c\u4f7f\u7528OTP\u7684\u8bdd\u5c3d\u91cf\u65f6\u95f4\u957f\u4e00\u4e9b\uff0c\u5426\u5219\u5ba2\u6237\u7aef\u9700\u8981\u91cd\u65b0\u8f93\u5165\u7528\u6237\u540d\u5bc6\u7801\u548cOTP\u4e00\u6b21\u6027\u5bc6\u7801\u3002\r\nreneg-sec 0<\/code><\/pre>\n<\/div>\n

\u7136\u540e\u9700\u8981\u914d\u7f6e\/etc\/openvpn\/auth\/ldap.conf<\/p>\n

\n
<LDAP>\r\n     URL    ldap:\/\/10.127.100.48:389\r\n     Timeout    15\r\n     TLSEnable  no\r\n     FollowReferrals yes\r\n<\/LDAP>\r\n\r\n<Authorization>\r\n     BaseDN \"ou=People,dc=ipcpu,dc=com\"\r\n     # User Search Filter\r\n     #SearchFilter  \"(&(uid=%u)(accountStatus=active))\"\r\n     SearchFilter   \"uid=%u\"\r\n\r\n     # Require Group Membership\r\n     RequireGroup   false\r\n     #@@@@\u6ce8\u610f\u4e0b\u9762\u8fd9\u4e2a\r\n     PasswordIsCR   true\r\n<\/Authorization><\/code><\/pre>\n<\/div>\n

\u5269\u4e0b\u7684\u5c31\u662f\u914d\u7f6eOTP\u76f8\u5173\u5185\u5bb9\u4e86,\/etc\/openvpn\/auth\/otp-secrets<\/p>\n

\n
ipcpu otp totp:sha1:base32:LJYHR64TUI7IL3RD::xxx *<\/code><\/pre>\n<\/div>\n

\/etc\/openvpn\/auth\/otp-secrets\u6587\u4ef6github\u4e0a\u7ed9\u51fa\u4e86\u5f88\u591a\u4f8b\u5b50\uff0c\u6211\u4eec\u5c31\u7528\u6700\u7b80\u5355\u7684GoogleAuthenticator\u4f8b\u5b50\uff0c\u4e2d\u95f4\u90a3\u4e32\"LJYHR64TUI7IL3RD\"\u5c31\u662f\u5bc6\u94a5\uff0c\u719f\u6089GoogleAuthenticator\u539f\u7406\u7684\uff0c\u53ef\u4ee5\u76f4\u63a5\u751f\u6210\u4e13\u7528\u5b57\u7b26\u4e32\u548c\u4e8c\u7ef4\u7801
\n
\n\u7528\u624b\u673a\u7aef\u626b\u4e00\u4e0b\u5c31\u53ef\u4ee5\u7528\u4e86\uff0c\u5982\u4e0b<\/p>\n

<\/p>\n

\u56db\u3001\u5ba2\u6237\u7aef\u914d\u7f6e<\/h2>\n

\u5ba2\u6237\u7aef\u914d\u7f6e\u6bd4\u8f83\u7b80\u5355\uff0c\u9664\u4e86\u5173\u95edkey\u8ba4\u8bc1\u4ee5\u5916\uff0c\u589e\u52a0auth-user-pass\u548cstatic-challenge\uff0c\u5982\u4e0b<\/p>\n

\n
client\r\ndev tun\r\nproto tcp\r\nresolv-retry infinite\r\nnobind\r\npersist-key\r\npersist-tun\r\nverb 3\r\ncomp-lzo\r\nremote-cert-tls server\r\nroute-delay 2\r\ncipher AES-256-CBC\r\nremote <SERVER-IP> 1194\r\nca ca.crt\r\n#cert client102.crt\r\n#key client102.key\r\nauth-user-pass\r\nauth-nocache\r\nstatic-challenge \"Enter Google Authenticator Token\" 1\r\n#@\u5f39\u51fa\u9a8c\u8bc1\u6846\uff0c1\u8868\u793a\u660e\u6587\u663e\u793a\uff0c0\u8868\u793a\u5bc6\u6587\u663e\u793a<\/code><\/pre>\n<\/div>\n

\u5ba2\u6237\u7aef\u767b\u9646\u7684\u754c\u9762\u5982\u4e0b
\n<\/p>\n

\u4e94\u3001\u5b89\u5168\u8003\u8651<\/h2>\n

\u901a\u8fc7\u4e0a\u9762\u7684\u63cf\u8ff0\uff0c\u5927\u5bb6\u4e5f\u57fa\u672c\u6e05\u695a\u4e86GoogleAuthenticator\uff0c\u8fd9\u53ea\u662f\u4e00\u4e2a\u5c06\u5171\u4eab\u79d8\u94a5\u8f6c\u5316\u4e3a\u4e00\u6b21\u6027\u5bc6\u7801\u7684\u5de5\u5177\u800c\u5df2\uff0c\u5982\u679c\u76f4\u63a5\u5c06\u751f\u6210\u7684QR\u7801\u53d1\u5230\u7528\u6237\u90ae\u7bb1\u91cc\uff0c\u90a3\u4e48\u8fd9\u4e00\u5c42\u5b89\u5168\u4fdd\u969c\u57fa\u672c\u5c31\u662f\u4e00\u4e2a\u6446\u8bbe\u3002<\/p>\n

\u5b9e\u9645\u751f\u4ea7\u73af\u5883\u8981\u591a\u65b9\u4f4d\u8003\u8651\uff0c\u5efa\u8bbe\u5b89\u5168\u8ba4\u8bc1\u4e2d\u5fc3\u3002<\/p>\n

\u53c2\u8003\u8d44\u6599<\/h2>\n

https:\/\/github.com\/threerings\/openvpn-auth-ldap<\/a>
\n
https:\/\/github.com\/evgeny-gridasov\/openvpn-otp<\/a><\/p>\n

<\/p>\n

<\/div>\n
<\/div>\n
\n
<\/div>\n
<\/div>\n
<\/div>\n
<\/div>\n
<\/div>\n<\/div>\n
\n
<\/div>\n
<\/div>\n
<\/div>\n
<\/div>\n
<\/div>\n<\/div>\n

<\/wiz_tmp_tag><\/p>\n

\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def<\/a> » OpenVPN\u542f\u7528LDAP+GoogleAuthenticator\u8ba4\u8bc1<\/a><\/p>","protected":false},"excerpt":{"rendered":"

OpenVPN\u542f\u7528LDAP+GoogleAuthenticator\u8ba4\u8bc1.md.md \u4e00\u3001\u6982\u8ff0 \u5728\u4e0a\u4e00\u7bc7\u6587\u7ae0\u5f53\u4e2d\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86openVPN+LDAP\u7684\u8ba4\u8bc1\u65b9\u5f0f\u3002 \u4f46\u5f80\u5f80\u5728\u4f01\u4e1a\u73af\u5883\u4e2d\uff0cLDAP\u7528\u6237\u540d\u5bc6\u7801\u53ef\u4ee5\u8bf4\u662f\u4e00\u53f7\u8d70\u5929\u4e0b\uff0c\u4e00\u65e6\u51fa\u73b0\u7528\u6237\u540d\u5bc6\u7801\u6cc4\u9732(\u7c97\u5fc3\u7a0b\u5e8f\u5458\u4f20\u5230github)\uff0c\u90a3\u635f\u5931\u662f\u5de8\u5927\u7684\uff0c\u56e0\u6b64\u52a0\u4e0a\u53cc\u56e0\u5b50\u8ba4\u8bc1\uff0c\u4e5f\u662f\u52a0\u4e0a\u4e86\u4e00\u5c42\u4fdd\u9669\u3002\u8fd9\u91cc\u6211\u4eec\u7684\u53cc\u56e0\u5b50\u8ba4\u8bc1\u662f\u901a\u8fc7GoogleAuthenticator\u5b9e\u73b0\u7684\uff0c\u56e0\u4e3a\u4ed6\u7684\u539f\u7406\u6bd4\u8f83\u7b80\u5355\uff0c\u5728\u4e1a\u5185\u4e5f\u5f88\u901a\u7528\u3002 \u4e8c\u3001\u5b89\u88c5 \u8981\u5b9e\u73b0LDAP+GoogleAuthenticator\u8ba4\u8bc1\uff0copenvpn\u9700\u8981\u5b89\u88c5\u4e24\u4e2a\u63d2\u4ef6 https:\/\/github.com\/threerings\/openvpn-auth-ldap https:\/\/github.com\/evgeny-gridasov\/openvpn-otp \u7b2c\u4e00\u4e2a\u5b9e\u73b0LDAP\u767b\u9646\uff0c\u7b2c\u4e8c\u4e2a\u5b9e\u73b0OTP\u3002\u7531\u4e8e\u4e24\u4e2a\u63d2\u4ef6\u5148\u540e\u987a\u5e8f\u9700\u8981\u517c\u5bb9\uff0c\u5fc5\u987b\u4f7f\u7528\u6700\u65b0\u7248\u672c\u3002 #@\u5b89\u88c5LDAP\u63d2\u4ef6 git clone https:\/\/github.com\/threerings\/openvpn-auth-ldap cd openvpn-auth-ldap #@\u5b89\u88c5\u4f9d\u8d56 yum install re2c libtool openldap openldap-devel openvpn openvpn-devel gcc-objc -y #@\u4e0b\u8f7d\u5b89\u88c5\u5305\u89e3\u538b\uff0c\u5f00\u59cb\u7f16\u8bd1 .\/regen.sh .\/configure –with-openldap=\/usr\/ –with-openvpn=\/usr\/ CFLAGS=”-fPIC” OBJCFLAGS=”-std=gnu11″ make make install #@\u5b89\u88c5OTP\u63d2\u4ef6 git clone https:\/\/github.com\/evgeny-gridasov\/openvpn-otp cd openvpn-otp yum install autoconf automake libtool* -y .\/autogen.sh .\/configure make make install \u5b89\u88c5\u5b8c\u6210\u540e\u53ef\u4ee5\u627e\u5230\u8fd9\u4e24\u4e2a\u63d2\u4ef6\u3002(.so\u6a21\u5757\u53ef\u4ee5\u4efb\u610f\u62f7\u8d1d\u5230\u5176\u4ed6\u76ee\u5f55\u4f7f\u7528\u7684) \/usr\/local\/lib\/openvpn-auth-ldap.so […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[194,17,193,191,15],"_links":{"self":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1211"}],"collection":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/comments?post=1211"}],"version-history":[{"count":3,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1211\/revisions"}],"predecessor-version":[{"id":1214,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1211\/revisions\/1214"}],"wp:attachment":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/media?parent=1211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/categories?post=1211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/tags?post=1211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}