Cent6系でmOTPを使ってみる
概要
sshの2段階認証できないかなーとちょっと試したメモです。
ぐぐると Google Authenticator 例が多いのですが、Mobile-OTP を今回は試してみました。
なるべく設定量は少なくするのが希望。
参考
大本 http://motp.sourceforge.net/
簡易MOTP生成 http://motp.sourceforge.net/motp_js.html
CLI版の簡易OTP検証 http://motp.sourceforge.net/bash/otpverify.sh
sshdの設定参考 http://konishi.me/?p=175
sshdの設定参考 http://serverfault.com/questions/487949/sshd-on-rhel-6-3-is-it-possible-to-use-requiredauthentications2-by-subnet
確認環境
CentOS6.5
※SELinux は落としました。
(Mobile-OTP が /var/cache/motp を使うのですがそこの権限付与が必要となるのですが、そこにちょっと手が回らなかったので)
パターン1:OTPでもパスワードでも可
/etc/ssh/sshd_config(authentication method: passwordで処理)
PasswordAuthentication yes ChallengeResponseAuthentication no
/etc/pam.d/sshd
先頭に以下を追加 auth sufficient pam_mobile_otp.so not_set_pass debug account required pam_mobile_otp.so debug password required pam_mobile_otp.so debug
パターン2:OTPとパスワード両方必要(authentication method: keyboard-interactiveで処理)
/etc/ssh/sshd_config
PasswordAuthentication yes ※ここはnoでも可Challengeが重要 ChallengeResponseAuthentication yes
/etc/pam.d/sshd
先頭に以下を追加 auth required pam_mobile_otp.so not_set_pass debug account required pam_mobile_otp.so debug password required pam_mobile_otp.so debug
番外:OTPと鍵認証が必要
パターン1,2に合わせて RequiredAuthentications2 での制御を追加
/etc/ssh/sshd_config
※パターン1用 RequiredAuthentications2 publickey,password ※パターン2用 RequiredAuthentications2 publickey,keyboard-interactive ※Match を使って特定アドレスからのみOTPを要求する形 Match Address *,!127.0.0.1 RequiredAuthentications2 publickey,password
できてないこと
SELinux有効化状態のまま運用すること。
→/var/cache/motp を扱えるように設定できればたぶん通せるはず。
pam での接続元による OTP Only等の細かい制御の確認
→設定方法を調査しきれず一旦保留扱い。pam から勉強になりそう…。