5.5. Ansible を使用して、Web コンソールで SSH ログイン用のスマートカード認証を設定する
RHEL Web コンソールでユーザーアカウントにログインすると、SSH プロトコルを使用してリモートマシンに接続できます。servicedelegationrule および servicedelegationtarget Ansible モジュールを使用して、制約付き委任機能用に Web コンソールを設定できます。これにより、再度認証を求められることなく SSH 接続が可能になります。
この手順例では、Web コンソールセッションは myhost.idm.example.com ホスト上で実行され、認証されたユーザーに代わって SSH を使用して remote.idm.example.com ホストにアクセスするように設定します。
前提条件
-
myhost.idm.example.comで IdMadminTicket-Granting Ticket (TGT) を取得した。 -
remote.idm.example.comへのrootアクセス権がある。 - Web コンソールを実行するホストは、IdM ドメインのメンバーである。
次の要件を満たすように Ansible コントロールノードを設定している。
-
ansible-freeipaパッケージがインストールされている。 -
この例では、
~/MyPlaybooks/ディレクトリーに、IdM サーバーの完全修飾ドメイン名 (FQDN) を使用して Ansible インベントリーファイルが作成されていると想定しています。 この例では、
secret.ymlAnsible Vault で管理者パスワードがipaadmin_password変数に格納されていことを前提としています。サンプル Playbook については
、/usr/share/doc/ansible-freeipa/playbooks/servicedelegationtargetおよび/usr/share/doc/ansible-freeipa/playbooks/servicedelegationruleディレクトリーを参照してください。詳細は、/usr/share/doc/ansible-freeipa/ディレクトリーのREADME-servicedelegationrule.mdおよびREADME-servicedelegationtarget.mdファイルを参照してください。
-
-
ターゲットノード (
ansible-freeipaモジュールが実行されるノード) が、IdM クライアント、サーバー、またはレプリカとして IdM ドメインに含まれている。
手順
~/MyPlaybooks/ディレクトリーに移動します。$ cd ~/MyPlaybooks/機密性の高い変数を暗号化されたファイルに保存します。
vault を作成します。
$ ansible-vault create secret.yml New Vault password: <vault_password> Confirm New Vault password: <vault_password>ansible-vault createコマンドでエディターが開いたら、機密データを<key>: <value>形式で入力します。ipaadmin_password: <admin_password>- 変更を保存して、エディターを閉じます。Ansible は vault 内のデータを暗号化します。
Terminal ページで、Web コンソールがユーザーセッション内に Service for User to Proxy (S4U2proxy) Kerberos チケットを作成したことを確認します。
$ klist … Valid starting Expires Service principal 05/20/25 09:19:06 05/21/25 09:19:06 HTTP/myhost.idm.example.com@IDM.EXAMPLE.COM …以下の内容で
web-console-smart-card-ssh.ymlPlaybook を作成します。委任対象の存在を確認するタスクを作成します。
--- - name: Playbook to create a constrained delegation target hosts: ipaserver vars_files: - /home/user_name/MyPlaybooks/secret.yml tasks: - name: Ensure servicedelegationtarget web-console-delegation-target is present ipaservicedelegationtarget: ipaadmin_password: "{{ ipaadmin_password }}" name: web-console-delegation-target対象ホストを委任ターゲットに追加するタスクを追加します。
- name: Ensure servicedelegationtarget web-console-delegation-target member principal host/remote.idm.example.com@IDM.EXAMPLE.COM is present ipaservicedelegationtarget: ipaadmin_password: "{{ ipaadmin_password }}" name: web-console-delegation-target principal: host/remote.idm.example.com@IDM.EXAMPLE.COM action: member委任ルールの存在を確認するタスクを追加します。
- name: Ensure servicedelegationrule delegation-rule is present ipaservicedelegationrule: ipaadmin_password: "{{ ipaadmin_password }}" name: web-console-delegation-ruleWeb コンソールクライアントサービスの Kerberos プリンシパルが制約付き委任ルールのメンバーであることを確認するタスクを追加します。
- name: Ensure the Kerberos principal of the web console client service is added to the servicedelegationrule web-console-delegation-rule ipaservicedelegationrule: ipaadmin_password: "{{ ipaadmin_password }}" name: web-console-delegation-rule principal: HTTP/myhost.idm.example.com action: member制約付き委任ルールが web-console-delegation-target 委任対象と関連付けられることを確認するタスクを追加します。
- name: Ensure a constrained delegation rule is associated with a specific delegation target ipaservicedelegationrule: ipaadmin_password: "{{ ipaadmin_password }}" name: web-console-delegation-rule target: web-console-delegation-target action: memberremote.idm.example.comで Kerberos 認証を有効にするタスクを追加します。- name: Enable Kerberos authentication hosts: remote.idm.example.com vars: sshd_config: GSSAPIAuthentication: true roles: - role: rhel-system-roles.sshd
- ファイルを保存します。
Ansible Playbook を実行します。Playbook ファイル、
secret.ymlファイルを保護するパスワードを格納するファイル、およびインベントリーファイルを指定します。$ ansible-playbook --vault-password-file=password_file -v -i inventory web-console-smart-card-ssh.yml