4
4

More than 3 years have passed since last update.

WorkSpacesに多要素認証(MFA)でログインする

Posted at

リモートワーク促進の足掛かりに

リモートワークの需要が高まっている今日。
AWS WorkSpacesを条件付きで最大50人のユーザーが無料で利用できるようになりました。WorkSpaceを使えば、場所を選ばずにログイン可能な仮想環境を提供することができます。

デフォルトではIDとパスワードでの認証となっていますが、ログインに多要素認証をプラスすることでよりセキュアに利用することが出来ます。

概要

WorkSpacesを利用開始して、Radiusサーバを用意し、Miceosoft ADとAD connectorを利用して
ログイン時にGoogle Authentication (OTP) で認証できるように設定していきます。
設定後はログイン画面にMFA codeが表示されます。
image.png

参考にしたサイト

構築手順

  • Workspacesを構築する
    • ここから作成できます。
      https://console.aws.amazon.com/workspaces
    • デフォルトで作成するとsimple ADが選択されるので、AD connectorと連携可能なMicrosoft ADを選択してください。
    • Microsoft ADは2つ以上のサブネットに跨って作成されるので、使えるサブネットを2つ以上用意してください。
    • Microsoft AD、AD connectorと同じVPCで作成してください。
  • RADIUSサーバーを構築する
    • EC2でAmazon Linux 2インスタンスを作成します。workspaces数台程度の環境でしたらt2.microで問題なく稼働します。
    • RADIUSサーバに必要なパッケージをインストールします。
$ sudo yum install freeradius freeradius-utils git gcc pam-devel qrencode qrencode-libs qrencode-devel autoconf automake libtool
  • gitからgoogle-authenticatorをクローンします。 ./bootstrap.sh以下のコマンドでgoogle-authenticatorのコンパイル、インストールを行います。
$ git clone https://github.com/google/google-authenticator-libpam.git
$ cd /home/ec2-user/google-authenticator-libpam/
$ ./bootstrap.sh
$ ./configure
$ make
$ sudo make install
  • RADIUSを有効にするユーザ用のグループを作成します。
$ sudo groupadd radius-enabled
  • 各種設定ファイルを修正します。
    /etc/raddb/radiusd.conf/etc/raddb/users/etc/raddb/sites-available/defaultです。
    今回のRADIUSサーバではLinuxのPAM (Pluggable Authentication Modules) を利用し、workspacesからのRADIUSサーバに対するワンタイムパスワードはPAM側の仕組みで Google AuthenticatorのPAMモジュールに連携し、認証します。
# /etc/raddb/radiusd.confのradiusdをrootに変更
user = root
group = root

# /etc/raddb/usersファイル内に追加
DEFAULT    Group != "radius-enabled", Auth-Type := Reject
           Reply-Message = "Your account has been disabled."
DEFAULT    Auth-Type := PAM

# /etc/raddb/sites-available/default
~省略~
#  Pluggable Authentication Modules.
pam ← コメントを外す
  • PAM側の設定ファイル/etc/pam.d/radiusdを以下の通りに修正し、GoogleAuthenticatorのPAMモジュールに連携させます。
#%PAM-1.0
#auth       include     password-auth
#account    required    pam_nologin.so
#account    include     password-auth
#password   include     password-auth
#session    include     password-auth
auth requisite pam_google_authenticator.so
account required pam_permit.so
session required pam_permit.so
  • RADIUSサーバのクライアント設定として/etc/raddb/clients.confに対して、workspacesやMicrosoft ADが所属するVPCからのアクセスを許可します。
client from-vpc {
    ipaddr     = 172.16.0.0
    netmask    = 16
    secret     = 複雑なパスワードを作成して記述します。後ほどAD connecto側に登録します。
    shortname  = workspaces-vpc
  • PAMモジュールのリンクを登録します。
$ sudo ln -s /etc/raddb/mods-available/pam /etc/raddb/mods-enabled/pam
$ sudo cp /usr/local/lib/security/pam_google_authenticator.so /usr/lib64/security
  • RADIUSを起動します。
$ systemctl enable radiusd
$ sudo systemctl start radiusd
  • WorkSpacesに実際にログインするユーザを追加します。
$ useradd -g radius-enabled workspaces-user
$ sudo -u user001 /usr/local/bin/google-authenticator

追加すると、認証に関して対話型で設定をするので、内容を確認して問題なければyを指定してください。

QRコードが表示されるので、ユーザのスマホでGoogle Authenticatorをインストールし、画面をスキャンして登録して下さい。
image.png

  • AD connectorを構築する
    WorkSpacesのMiceosoft ADと連携する形で構築します。ドメイン名はMiceosoft ADと同じものを指定し、DNSアドレスはMiceosoft ADのプライベートIPアドレスを指定します。 image.png

設定時に[Multi-Factor Authentication]の項目を以下のように設定します。

項目名 設定値
Enable Multi-Factor Authentication チェックボックスをオン
RADIUS server IP address(es) 構築したRADIUSサーバのプライベート IP アドレス
Port 1812 を入力
Shared secret code /etc/raddb/clients.conf に設定したパスワード
Confirm shared secret code 同上
Protocol PAP を選択
Server timeout (in seconds) 例 10
Max retries 例 5
  • RADIUSとAD connectorを接続する [RADISU Status] が [Complete] になっている事を確認します。
    この状態になるとログイン画面にMFA codeが表示されます。 image.png

導入時

Workspacesは作成時にユーザにログイン通知メールが配信されるので、
事前にユーザに対してスマホに対するGoogle Authenticationのインストールとログイン方法の説明を忘れないようにしましょう。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4