最終更新: bakuryukai 2016年04月21日(木) 21:38:43履歴
AWSに構築したAmazon Linux(4.4.5-15.26.amzn1.x86_64)
OpenVPNは実装済みとする
OTP表示用のアプリは色々あるけどIIJ SmartKeyがいいよ。
OpenVPNは実装済みとする
OTP表示用のアプリは色々あるけどIIJ SmartKeyがいいよ。
RPMがあるのでコマンド一発
# yum install google-authenticatorそれ以外のOSの場合はソースからインストール?
# hg clone https://google-authenticator.googlecode.com/hg/ google-authenticator # cd google-authenticator/libpam # make && make install
※下部4行以外は環境に応じて
# vim /etc/openvpn/server.conf ;local a.b.c.d port 1194 proto udp dev tun ca ca.crt cert server.crt key server.key dh dh2048.pem server 10.254.254.0 255.255.255.0 ifconfig-pool-persist ipp.txt push "route 172.31.0.0 255.255.0.0" keepalive 10 120 comp-lzo user nobody group nobody persist-key persist-tun status /var/log/openvpn-status.log ;log openvpn.log log-append /var/log/openvpn.log verb 3 ;----- password and otp auth ----- plugin /usr/lib64/openvpn/plugin/lib/openvpn-auth-pam.so openvpn client-cert-not-required username-as-common-name reneg-sec 0
OpenVPNクライアントから2段階認証ができないので
forward_passでスタックする(詳細は後述)
forward_passでスタックする(詳細は後述)
# vim /etc/pam.d/openvpn #%PAM-1.0 auth required pam_env.so auth requisite pam_google_authenticator.so forward_pass auth required pam_unix.so use_first_pass account required pam_unix.so
google-authenticatorはコマンドオプションで非対話でやれるけど
とりあえず素で実行。全部yでおk。
※Google純正のやつでもいいけど、ロックができないから微妙。
とりあえず素で実行。全部yでおk。
# useradd vpnuser01 # passwd vpnuser01 # su vpnuser01 # google-authenticator Do you want authentication tokens to be time-based (y/n) y https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/vpnuser01@[サーバー名]%3Fsecret%3XXXXXXXXXXXXXXXXX Your new secret key is: XXXXXXXXXXXXXXXX Your verification code is XXX Your emergency scratch codes are: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX Do you want me to update your "/home/vpnuser01/.google_authenticator" file (y/n) y Do you want to disallow multiple uses of the same authentication token? This restricts you to one login about every 30s, but it increases your chances to notice or even prevent man-in-the-middle attacks (y/n) y By default, tokens are good for 30 seconds and in order to compensate for possible time-skew between the client and the server, we allow an extra token before and after the current time. If you experience problems with poor time synchronization, you can increase the window from its default size of 1:30min to about 4min. Do you want to do so (y/n) y If the computer that you are logging into isn't hardened against brute-force login attempts, you can enable rate-limiting for the authentication module. By default, this limits attackers to no more than 3 login attempts every 30s. Do you want to enable rate-limiting (y/n) yIIJ SmartKeyとかで上記のURLに表示されるQRコードを読み込む
※Google純正のやつでもいいけど、ロックができないから微妙。
CA証明書は必要なので埋め込んでおく
# vim client.ovpn client dev tun proto udp remote <サーバーアドレス> 1194 resolv-retry infinite nobind persist-key persist-tun comp-lzo verb 3 auth-user-pass reneg-sec 0 <ca> -----BEGIN CERTIFICATE----- MIID0TCCAzqgAwIBAgIJAPqGBlghO9ltMA0GCSqGSIb3DQEBBQUAMIGiMQswCQYD ...(省略)... YkkWu76TYGhSGhOg7ATRSGMVwlHO -----END CERTIFICATE----- </ca>
vpnux上記のovpnをインポートする。・・・あれ、できたっけ?
ユーザー認証は下記の要領で。
ユーザー認証は下記の要領で。
ユーザー名:ユーザーID パスワード:<パスワード><OTPに表示される6桁数値>*パスワードに続けてそのまま書く
タグ
コメントをかく