Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

IBM Verify Gateway for Linux PAM を試してみた

Posted at

IBM Verify Gateway for Linux PAM を試してみた

はじめに

Linuxサーバーで多要素認証(MFA)を実現するために、IBM Security Verify Gateway Linux PAM を検証しました。
この記事では、セットアップ手順などをまとめます。


IBM Verify Gateway for Linux PAMとは?

IBM Security Verify Gateway for Linux PAM は、オンプレやクラウド環境で多要素認証を提供するソリューションです。
Linux PAMと連携することで、LinuxへのSSHログイン時、ローカルログイン時、sudoの実行時などに多要素認証を追加できます。

IBM Verify Gateway には、以下のように各種OS用の多要素認証を提供します。

  • AIX用のIBM Security Verify Gateway for AIX PAM
  • Linux用のIBM Security Verify Gateway for Linux PAM
  • Windows用の IBM Security Verify Gateway for Windows
  • RADIUS用のIBM Security Verify Gateway for RADIUS

IBM Verify Gateway for Linux PAM / IBM Verify Gateway for AIX PAM の対象OS

対象OSについては、製品のマニュアルページに記載があるため、その記載内容をご確認ください。IBM Verify Gateway for Linux PAM をダウンロードすると、以下のように各種Linux OS用のファイルが含まれています。

  • debian-10.zip
  • debian-11.zip
  • debian-12.zip
  • debian-13.zip
  • fedora-38.zip
  • opensuse-12.zip
  • opensuse-15.zip
  • opensuse-42.3.zip
  • rhel-7.zip
  • rhel-8.zip
  • rhel-9.zip
  • centos-7.zip
  • centos-8.zip

参考: マニュアル IBM Verify Gateway for Linux PAM and AIX PAM


セットアップ手順

OSの準備

今回の検証では Red Hat Enterprise Linux 9 を利用しています。

IBM Verify Gatewayのインストール

インストールの手順は、基本的にはマニュアルの記載に沿って実行すれば、インストールができます。

1. メディアのダウンロード

IBM Verify Gateway for Linux PAM をダウンロードします。
https://exchange.xforce.ibmcloud.com/hub に進みます。
IBMidでログインします。
検索バーに gateway for linux と入力し検索すると、1件見つかります。
image.png

ダウンロードしたzipファイル (ISVGForLinuxPAM1070.zip) を、IBM Verify Gateway for Linuxのインストール先となるLinuxマシンにコピーします。

2. インストール

Linuxマシンにログインし、ISVGForLinuxPAM1070.zipを展開します。
展開後、OSの種類にあったzipファイルを展開します。
RPMを適用します。

# RPMを適用します
sudo rpm -ihv ibm-auth-api-1.0.7.0-0.x86_64.rpm
sudo rpm -ihv pam-ibm-auth-1.0.7.0-0.x86_64.rpm

3. 構成ファイル、PAMの設定、SSHDの構成

Gateway for Linux PAM では以下のような構成ファイルを利用します。
OS標準のもの、Gateway for Linuxで編集するものなどがありますので、概要をここに記載します。

ファイル名 用途・変更内容
/etc/pam.d/sshd LinuxでSSHログイン時の認証を制御するPAMの設定ファイル。以下を設定する。

auth substack civ-auth-choice
/etc/pam.d/sshd_without_isv sshdの編集前のもの。IBM Verifyを利用した多要素認証構成にしていないもの。このファイルは編集せずに残しておく。
/etc/pam.d/password-auth LinuxのPAMでパスワード認証を制御する設定ファイル。
civ-password-authにこのファイルをコピーして作成し、civ-password-authを編集する。このファイル(password-auth)は編集せず残しておく。
/etc/pam.d/civ-password-auth 以下行を見つけ、記載を変更する
auth sufficient pam_unix.so nullok try_first_pass

以下のように変更する
#auth sufficient pam_unix.so nullok try_first_pass
auth requisite pam_unix.so nullok try_first_pass
auth sufficient pam_ibm_auth.so auth_method=choice-then-otp exempt_group=nomfa
/etc/pam_ibm_auth.json Gateway for Linux PAM の設定ファイル。
IBM VertifyのURLやAPIクライアントの設定等をする。*** で記載されている箇所を利用する環境に合わせて設定をしたり、必要に応じコメントアウトされているデバッグログの出力をできるようにする。
/etc/pam_ibm_auth.json_sample Gateway for Linux PAM の設定ファイルの雛形。編集せずに残しておく。
/etc/ssh/sshd_config SSHサーバー(sshd)の動作の設定ファイル。以下を設定する

UsePAM yes
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication yes
KbdInteractiveAuthentication yes
PasswordAuthentication yes
/etc/ssh/sshd_config.d/50-redhat.conf 設定ファイルのsshd_configに加えて、このファイルの設定が読み込まれる。sshd_configで設定している値が有効にならない場合、このファイルの設定を確認する。この例では以下のパラメータをコメントアウトする。

# ChallengeResponseAuthentication no

civ-password_auth を作成する

/etc/pam.d/password_auth をコピーして /etc/pam.d/civ-password-auth を作成します。

sudo cp -p /etc/pam.d/password-auth /etc/pam.d/civ-password-auth
cat /etc/pam.d/civ-auth-choice

以下行を見つけ、記載を変更します。
auth sufficient pam_unix.so nullok

以下のように変更する
#auth sufficient pam_unix.so nullok
auth requisite pam_unix.so nullok
auth sufficient pam_ibm_auth.so auth_method=choice-then-otp exempt_group=nomfa

変更後の /etc/pam.d/civ-auth-choice
# Generated by authselect on Mon Dec  8 13:28:05 2025
# Do not modify this file manually.

auth        required                                     pam_env.so
auth        required                                     pam_faildelay.so delay=2000000
auth        [default=1 ignore=ignore success=ok]         pam_usertype.so isregular
auth        [default=1 ignore=ignore success=ok]         pam_localuser.so
#auth        sufficient                                   pam_unix.so nullok
auth        requisite                                    pam_unix.so nullok
auth        sufficient                                   pam_ibm_auth.so auth_method=choice-then-otp exempt_group=nomfa

auth        [default=1 ignore=ignore success=ok]         pam_usertype.so isregular
auth        sufficient                                   pam_sss.so forward_pass
auth        required                                     pam_deny.so

account     required                                     pam_unix.so
account     sufficient                                   pam_localuser.so
account     sufficient                                   pam_usertype.so issystem
account     [default=bad success=ok user_unknown=ignore] pam_sss.so
account     required                                     pam_permit.so

password    requisite                                    pam_pwquality.so local_users_only
password    sufficient                                   pam_unix.so sha512 shadow nullok use_authtok
password    [success=1 default=ignore]                   pam_localuser.so
password    sufficient                                   pam_sss.so use_authtok
password    required                                     pam_deny.so

session     optional                                     pam_keyinit.so revoke
session     required                                     pam_limits.so
-session    optional                                     pam_systemd.so
session     [success=1 default=ignore]                   pam_succeed_if.so service in crond quiet use_uid
session     required                                     pam_unix.so
session     optional                                     pam_sss.so

/etc/pam.d/sshd を編集する。

変更前
auth substack password-auth
変更後
auth substack civ-password-auth

#%PAM-1.0
auth       substack     civ-password-auth
auth       include      postlogin
account    required     pam_sepermit.so
account    required     pam_nologin.so
account    include      password-auth
password   include      password-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    required     pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session    required     pam_selinux.so open env_params
session    required     pam_namespace.so
session    optional     pam_keyinit.so force revoke
session    optional     pam_motd.so
session    include      password-auth
session    include      postlogin

/etc/pam_ibm_auth.json を編集する

以下のファイルがあることを確認します。

ls -l /etc/pam_ibm_auth.json*
-r--------. 1 root root 733 10月 16  2024 /etc/pam_ibm_auth.json
-r--------. 1 root root 733 10月 16  2024 /etc/pam_ibm_auth.json.sample

このファイルのうち、pam_ibm_auth.json の方を編集します。

編集前の/etc/pam_ibm_auth.json
{
    "ibm-auth-api":{
        "client-id":"********-****-****-****-************",
        "obf-client-secret":"**********", /* Use /opt/ibm/ibm_auth/ibm_authd[_64] --obf <secret> */
        "protocol":"https",
        "host":"****.verify.ibm.com",
        "port":"443",
        "max-handles":"16"
    },
    "ibm-authd":{
        /* "trace-file":"/tmp/ibm_authd.log" */
    },
    "pam":{
        /* "trace-file":"/tmp/pam_ibm_auth.log" */
/*
        "pam-ibm-auth": {
            "additional-args": [
                "auth_method=choice-then-otp",
                "add_devices_to_choice",
                "gecos_field=6",
                "gecos_separator=/",
                "failmode_insecure"
            ]
        }
*/
    }
}

*** のところは、環境に合わせて編集します。

項目名 用途・変更内容
"client-id" IBM Verify の API クライアントのクライアントID
"obf-client-secret" IBM Verify の API クライアントのクライアントシークレットを難読化した文字列
"host" ご利用する IBM Verify のURL

APIクライアントは、IBM Verifyにログインし、管理コンソールから作成します。
セキュリティー > APIアクセス から APIクライアントを作成します。
必要な権限を設定して作成後、APIクライアントの「接続の詳細」を確認します。
以下のような画面が表示され、クライアントID、クライアント・シークレットを確認することができます。
image.png

クライアント・シークレットは以下のように難読化します。

sudo /opt/ibm/ibm_auth/ibm_auth_64 --obf クライアントシークレット

長い文字列(検証した際は 65文字でした)が出力されます。
この長い文字列を"obf-client-secret" に設定します。
実行する都度、異なる文字列が出力されるため、出力された文字列を適宜保管しておくようにします。

/etc/ssh/sshd_config

/etc/ssh/sshd_config を編集します。

sudo cp -p /etc/ssh/sshd_config /etc/ssh/sshd_without_isv

以下の2つを設定します。
UsePAM yes
ChallengeResponseAuthentication yes

# Change to no to disable s/key passwords
KbdInteractiveAuthentication yes
ChallengeResponseAuthentication yes
#UsePAM no
UsePAM yes
PasswordAuthentication yes

/etc/ssh/sshd_config.d/50-redhat.conf

/etc/ssh/sshd_config で設定をしたパラメータが、このファイルで設定されていると、このファイルの設定が有効になります。ChallengeResponseAuthentication no の設定が記載されているので、これをコメントアウトし、sshd_config の設定を活かすか、このファイルでも yes に設定するかを行います。

# ChallengeResponseAuthentication no

多要素認証を除外するグループ

多要素認証を除外するグループを作成し、必要に応じ、グループのメンバーにユーザーを追加します。

sudo groupadd -f nomfa
sudo usermod -aG nomfa <username>

4. 動作確認

SSHログイン時にMFAプロンプトが表示されることを確認します。
(IBM Verify 側にも、対応するユーザーが登録されている必要があります)

5. ハマりポイント

SELinuxにより sshd が IBM Verify に接続ができない

IBM Verify側でユーザーの多要素認証を設定していない

No second factor authentication enrollments are available.
pam_sm_authenticate(): 9 DONE

/etc/ssh/sshd_config.d/50-redhat.conf の設定により sshd_config の設定が有効にならない

今回の検証では ChallengeResponseAuthentication yes が有効にならなかったのですが、他の設定についても同様です。/etc/ssh/sshd_config.d の下に、他のファイルがある場合も、同様の考慮が必要になります。
sshd -T コマンドを実行することで、実際に有効になっている値がわかります。

$ sudo sshd -T
[sudo] user01 のパスワード:
port 22
addressfamily any
listenaddress [::]:22
listenaddress 0.0.0.0:22
usepam yes
logingracetime 120
x11displayoffset 10
x11maxdisplays 1000
(省略)
kbdinteractiveauthentication no
(省略)

具体的に設定パラメータがどこで設定されているかなど

grep -i ChallengeResponseAuthentication /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*
/etc/ssh/sshd_config:ChallengeResponseAuthentication yes
/etc/ssh/sshd_config.d/50-redhat.conf:ChallengeResponseAuthentication no

sshd の構成ファイルの記述ミスなどがないか、以下のコマンドを実行して確認します。

sshd -t

6. まとめ

Linux PAMとIBM Verify GatewayでMFAを追加でき、OS利用者はIBM Verifyに多要素認証の設定をすれば、それぞれのOSに設定をすることなく、多要素認証を利用することができます。
サーバーの台数が多く、多要素認証の設定の作業負担が多い場合には、効率的に管理することができます。設定にあたっては、OSのPAMの機能を利用しているため、すでに別のPAMツールを利用している場合などには利用できない場合があります。

参考リンク

IBM公式ドキュメント
IBM Verify Gateway for Linux PAM and AIX PAM
(https://www.ibm.com/docs/ja/security-verify?topic=mpi-verify-gateway-linux-pam-aix-pam-pluggable-authentication-modules)

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?