다중 요소 인증(MFA)에 AWS Single Sign-ON 대응

(2019-10-25 Update)
AWS Single Sign-on은 MFA 애플리케이션을 사용하는 다요소 인증에 단독으로 대응하기 때문에 RADIUS를 따로 준비할 필요가 없다.
https://aws.amazon.com/jp/about-aws/whats-new/2019/10/increase-aws-single-sign-on-security-with-multi-factor-authentication-using-authenticator-apps/
(2019-01-19 Update)
AWS Single Sign-on을 통해 로그인할 때 E-Mail 기반 인증이 가능합니다.
https://qiita.com/daimatsu/items/666319c2209cbbcd4aa8

개요

  • AWS Single Sign-ON에 MFA(다요소 인증)를 추가하는 방법
  • FreeRADIUS와 GoogleAuthenticator를 이용하여 실현
  • 참고 자료


    RADIUS 서버의 구축은 다음과 같은 AWS 공식 블로그를 기반으로 합니다.
    워크스페이스의 다요소 인증에 관한 것이지만 RADIUS 서버의 설정과 관련한 정보는 그대로 사용할 수 있다.

    프로비저닝

  • Google Authenticator가 설치된 스마트폰을 다요소 인증 장비로 사용한다.
  • 인증 기반으로 AD 커넥터를 EC2 인스턴스로 구성된 Active Directory 환경에 연결합니다.
  • RADIUS 서버는 FreeRADIUS를 사용합니다.

  • 절차.

  • 스마트폰 앱 설치 Google Authenticator
  • RADIUS Server 구축
  • AWS Directory Service 설정
  • AWS Single Sign-ON의 설정
  • 스마트폰 애플리케이션 Google Authenticator 설치


    여기서부터 설치해.
    Android: https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=ja
    iPhone: https://itunes.apple.com/jp/app/google-authenticator/id388497605?mt=8

    RADIUS 서버 구축


    EC2 인스턴스에 RADIUS 서버를 구축합니다.

    FreeRADIUS 및 기타 필요한 패키지 설치

    $ sudo yum -y update
    $ sudo yum -y install freeradius freeradius-utils git gcc pam-devel qrencode qrencode-libs qrencode-devel autoconf automake libtool
    

    소스에서 Google Authenticator PAM module 설치


    GiitHub에서 소스 파일을 다운로드한 후 설치합니다.
    $ git clone https://github.com/google/google-authenticator-libpam.git
    $ cd google-authenticator-libpam
    $ ./bootstrap.sh  
    $ ./configure
    $ make
    $ sudo make install
    

    OS 설정

  • RADIUS 인증을 받을 수 있는 그룹을 만듭니다.
  • Google Authenticator에 등록 컨텐트에 대한 설명으로 사용자 이름@호스트 이름이 표시되므로 호스트 이름에 이해하기 쉬운 이름이 붙습니다.
  • 그룹 생성
    $ sudo groupadd radius-enabled
    
    호스트 이름 변경
    # ホスト名は適宜、DNSで名前解決できる必要はありません。
    $ sudo hostnamectl set-hostname mfa.example.com
    
    /etc/hosts
    # このEC2インスタンスのIPを指定
    xxx.xxx.xxx.xxx mfa.example.com 
    

    FreeRADIUS 설정


    PAM을 사용하여 인증하려면 루트 사용자를 사용해야 합니다.
    /etc/raddb/radiusd.conf
    --- radiusd.conf.def    2019-01-07 08:28:13.122132617 +0000
    +++ radiusd.conf        2019-01-07 08:29:06.218050333 +0000
    @@ -435,8 +435,8 @@
            #  member.  This can allow for some finer-grained access
            #  controls.
            #
    -       user = radiusd
    -       group = radiusd
    +       user = root
    +       group = root
    
            #  Core dumps are a bad thing.  This should only be set to
            #  'yes' if you're debugging a problem with the server.
    
    radius-enabled PAM을 사용하는 그룹만 설정합니다.
    etc/raddb/users
    --- users.def   2019-01-07 08:34:43.485527661 +0000
    +++ users       2019-01-07 08:36:06.921398359 +0000
    @@ -64,6 +64,9 @@
     #DEFAULT       Group == "disabled", Auth-Type := Reject
     #              Reply-Message = "Your account has been disabled."
     #
    +DEFAULT        Group != "radius-enabled", Auth-Type := Reject
    +       Reply-Message = "Your account has been disabled."
    +DEFAULT        Auth-Type := PAM
    
     #
     # This is a complete entry for "steve". Note that there is no Fall-Through
    
    /etc/raddb/sites-available/default
    --- default.def 2019-01-07 08:40:04.841029649 +0000
    +++ default     2019-01-07 08:40:24.072999845 +0000
    @@ -510,7 +510,7 @@
    
            #
            #  Pluggable Authentication Modules.
    -#      pam
    +       pam
    
            #  Uncomment it if you want to use ldap for authentication
            #
    
    $ sudo ln -s /etc/raddb/mods-available/pam /etc/raddb/mods-enabled/pam
    
  • FreeRADIUS는 PAM 인증 시 Google Authenticator를 사용하는 PAM 모듈로 설정합니다.
  • pam_google_authenticator.so 경로가 통과하는 곳으로 복사하거나 전보로 쓰십시오.
  • /etc/pam.d/radiusd
    --- radiusd.def 2019-01-07 08:42:40.052789114 +0000
    +++ radiusd     2019-01-07 08:43:28.216714473 +0000
    @@ -1,6 +1,9 @@
     #%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       include    password-auth
    +#account    required   pam_nologin.so
    +#account    include    password-auth
    +#password   include    password-auth
    +#session    include    password-auth
    +auth requisite /usr/local/lib/security/pam_google_authenticator.so
    +account required pam_permit.so
    +session required pam_permit.so
    
    RADIUS 프로토콜에 연결할 서브넷 및 연결 암호를 설정합니다.
    /etc/raddb/clients.conf
    --- clients.conf.def    2019-01-07 08:45:45.584501591 +0000
    +++ clients.conf        2019-01-07 08:48:22.312258707 +0000
    @@ -248,6 +248,11 @@
     #      secret          = testing123-2
     #}
    
    +client shared-service {
    +       ipaddr = x.x.x.x/y #実際にお使いの VPC ネットワークアドレス等を指定して下さい
    +       secret = xxxxxxxxxx
    +}
    

    FreeRADIUS 시작

    $ sudo systemctl enable radiusd
    $ sudo systemctl start radiusd
    

    사용자 등록

  • Active Directory와 이름이 같은 사용자를 만든 후 Google Authenticatory의 사용자 설정을 수행해야 합니다.
  • 명령을 실행하면 영어로 몇 가지 문제가 표시됩니다.모든 y 다 괜찮아요.

  • 콘솔에 표시된 QR 코드를 스마트폰 애플리케이션의 Google Authenticator를 통해 스캔한 후 로그인합니다.
  • 브라우저에서 첫 번째 질문을 연 후 표시되는 URL에도 QR 코드를 가져올 수 있습니다.
  • $ sudo useradd -g radius-enabled username0 # 実際のユーザー名に合わせてください
    $ sudo -u username0 /usr/local/bin/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/chart?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
    [QR コード]
    
    Your new secret key is: xxxxxxxxxxxx
    Enter code from app (-1 to skip):
    
    몇 가지 문제의 내용은 다음과 같다.
    Do you want authentication tokens to be time-based (y/n)
    시간 기반 인증 토큰을 사용하시겠습니까?
    Do you want me to update your "/home/XXXXXX/.google_authenticator"file (y/n)
    파일을 업데이트하시겠습니까?
    업데이트하지 않으면 표시된 QR 코드로 로그인할 수 없습니다.
    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)
    동일한 인증 영패를 여러 번 사용하는 것을 금지합니까?이 제한에 따라 30초에 한 번만 접속할 수 있지만 중간인 공격이나 금지에 주의할 가능성이 높다.
    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)
    기본적으로 영패는 30초에 한 번씩 사용되며, 현재 시간 전이나 이후의 영패에서도 이 영패를 허용하여 클라이언트와 서버의 시간 이동에도 대응할 수 있습니다.만약 시간 동기화 상태가 좋지 않고 문제가 있으면 기본 1분 반의 창을 약 4분으로 확장할 수 있습니다.진행하시겠습니까?
    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)
    로그인한 컴퓨터가 총 공격에 의해 보호되지 않으면 인증 모듈을 통해 횟수를 제한할 수 있습니다.이 제한은 30초 동안 3회 이상 로그인을 시도할 수 없습니다.횟수 제한을 실시합니까?

    사용자 인증 테스트

  • [usename] 에서 실제 사용자 이름을 지정하십시오.
  • [OneTimePassword]에 스마트폰 애플리케이션의 Google Authenticator에 표시된 1시간 비밀번호를 입력하십시오.
  • [IPAddress]에 RADIUS 서버의 개인 IP를 입력하십시오.
  • [RADIUSPassword]에서conf에 설정된 암호를 입력하십시오.
    $ radtest [username] [OneTimePassword] [IPAddress]:1812 10 [RADIUSPassword]
    
    Sent Access-Request Id 81 from 0.0.0.0:47762 to [IPAddress]:1812 length 78
            User-Name = "[username]"
            User-Password = "[OneTimePassword]"
            NAS-IP-Address = [IPAddress]
            NAS-Port = 10
            Message-Authenticator = 0x00
            Cleartext-Password = "[OneTimePassword]"
    Received Access-Accept Id 81 from [IPAddress]:1812 to 0.0.0.0:0 length 20
    

    Directory Service 구축

  • AD connecter를 기존 AD 환경에 연결하여 사용합니다.
  • AD 환경 설정이 종료되었습니다.
  • AD 커넥터 구성


    카탈로그 유형 AD 커넥터를 선택합니다.

    크기에 따라 디렉터리 크기를 선택하십시오.

    사용 환경에 따라 VPC 및 서브넷을 선택하십시오.지정된 VPC 서브넷에 AD 커넥터를 생성합니다.

    AD에 대한 연결 정보를 설정합니다.

    다중 요소 인증 사용


    작성된 디렉토리를 선택하고 네트워크 및 보안 탭에서 다중 요소 인증을 활성화합니다.

    RADISU 서버에 대한 정보를 입력합니다.
  • 표시 레이블, IP 주소, 공유 기밀을 적절하게 설정하십시오.
  • 다른 항목은 기본값일 수 있습니다.

  • AWS Single Sign-ON 설정


    생성된 Directory Service(AD Connector)를 지정합니다.

    AWS 계정에 사용자를 할당합니다.

    사용자를 찾아 선택합니다.

    액세스 권한을 설정합니다.

    로그인


    사용자 포털을 방문하여 정상적으로 로그인하다.

    코드를 확인해야 하기 때문에 여기에 MFA 코드를 입력한다.

    기타 정보


    Directory Service 정보
  • 기존의 AD 환경을 상상하고 AD connector를 사용하거나 AWS Managed Microsoft AD를 사용할 수 있습니다.
  • Directconnect 또는 IPsecVPN으로 VPN을 연결하여 VPC와 ON 예비 연결 사이를 연결할 때 AD 커넥터의 연결 목적지를 ON 예비 AD 환경으로 설정할 수 있다.
  • Simple AD는 다중 요소 인증을 지원하지 않습니다.
  • 일회용 암호 응용 프로그램 정보
  • Google Authenticator PAM module을 사용하지만 Google Authenticator 이외의 어플리케이션도 사용할 수 있습니다.
  • 예: Authy,IIJ SmartKey
  • 좋은 웹페이지 즐겨찾기