- はじめに
- 1.OpenVPNにOTP認証を設定する
- 2.スマホ(Android)にIIJ Smartkeyアプリを導入・設定する
- 3.VPNクライアント(vpnux Client)の設定と接続
- 参考記事
はじめに
ワンタイムパスワード(OTP)認証とは?
一定期間のみ有効なパスワードを生成し、認証に使う。
VPNサーバのセキュリティについて
外部から自宅LAN内へのアクセスできるVPNは第三者による不正アクセスのリスクが存在する。
不正アクセスを防ぐためにもVPNの通信を確立する際の認証は何重にもしておきたい。
本ブログではすでに証明書を使った認証を紹介しているが
本稿により証明書認証+ID/Pass認証+OTP認証を実現できる。
ワンタイムパスワード認証の構成
今回はGoogleが開発した「Google Authenticator」の
時間同期式のワンタイムパスワードを使って実現する。
ワンタイムパスワード管理アプリは「IIJ Smartkey」を使う。
設定の流れ
1.OpenVPNにOTP認証を設定する
Google Authenticator のインストール
# yum -y install google-authenticator
PAM(Pluggable Authentication Module)と呼ばれる認証処理を実行するモジュールを利用する為、
下記のファイルが存在することを確認する
/etc/pam.d/login
/usr/lib64/openvpn/plugins/openvpn-plugin-auth-pam.so
OpenVPNの設定ファイルに下記を記載する
/etc/openvpn/server.conf
plugin /usr/lib64/openvpn/plugins/openvpn-plugin-auth-pam.so openvpn
OpenVPNで使用するPAMのファイルを作成する
# vi /etc/pam.d/openvpn #%PAM-1.0 auth required pam_env.so auth required pam_google_authenticator.so forward_pass auth required pam_unix.so use_first_pass account required pam_unix.so
VPNユーザの作成
# useradd vpnuser # passwd vpnuser
google-authenticator の設定
※対話の質問(y/n)はすべて「y」でOK
※設定内で表示されるURLは後で使うので控える
# su vpnuser # google-authenticator Do you want authentication tokens to be time-based (y/n) y Warning: pasting the following URL into your browser exposes the OTP secret to Google: https://www.google.com/*** Your new secret key is: *** Your verification code is *** Your emergency scratch codes are: *** *** *** *** *** Do you want me to update your "/home/vpnuser/.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, a new token is generated every 30 seconds by the mobile app. 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. This allows for a time skew of up to 30 seconds between authentication server and client. If you experience problems with poor time synchronization, you can increase the window from its default size of 3 permitted codes (one previous code, the current code, the next code) to 17 permitted codes (the 8 previous codes, the current code, and the 8 next codes). This will permit for a time skew of up to 4 minutes between client and server. 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) y
2.スマホ(Android)にIIJ Smartkeyアプリを導入・設定する
1.google-authenticatorで控えたURLをPCのブラウザで開くとQRコードが表示される
2.Google Playストアで「IIJ SmartKey」を検索し、インストールする
3.IIS SmartKeyを起動し、「+」を押す
4.カメラが起動するのでブラウザに表示されたQRコードを読み込む
5.アカウント名を入力し、登録を押す
6.表示された番号がワンタイムパスワードになる
3.VPNクライアント(vpnux Client)の設定と接続
vpnux Client を起動
ID/Pass認証を有効にする
プロファイルの編集の一般設定で
「ID/パスワード認証を使用」にチェックを入れる
ワンタイムパスワードを使った接続
パスワードの入力時にvpnuserのパスワードの後にOTPパスワードを入力する
ユーザ名 | vpnuser |
パスワード | <vpnuserのパスワード>+<OTPパスワード> |
参考記事
OpenVPNでパスワード+OTPの2要素認証をしたい - インフラエンジニアのメモ
EOF