29.7. Ansible を使用して Web コンソールを設定し、スマートカードで認証されたユーザーが再認証を求められることなくリモートホストに SSH 接続できるようにする

RHEL の Web コンソールでユーザーアカウントにログインした後、Identity Management (IdM) システム管理者として、SSH プロトコルを使用してリモートマシンに接続する必要がある場合があります。制約付き委任 機能を使用すると、再度認証を求められることなく SSH を使用することができます。

servicedelegationrule および servicedelegationtarget ansible-freeipa モジュールを使用して、制約付き委任を使用するように Web コンソールを設定するには、この手順に従います。以下の例では、Web コンソールセッションは myhost.idm.example.com ホストで実行され、認証されたユーザーの代わりに SSH を使用して remote.idm.example.com ホストにアクセスするように設定されています。

前提条件

  • IdM admin パスワードがある
  • remote.idm.example.com への root アクセスがある
  • Web コンソールサービスが IdM に存在する
  • remote.idm.example.com ホストが IdM に存在する
  • Web コンソールは、ユーザーセッションに S4U2Proxy Kerberos チケットを作成している。これを確認するために、IdM ユーザーで Web コンソールにログインし、Terminal ページを開き、以下を入力します。

    $ klist
    Ticket cache: FILE:/run/user/1894000001/cockpit-session-3692.ccache
    Default principal: user@IDM.EXAMPLE.COM
    
    Valid starting     Expires            Service principal
    07/30/21 09:19:06 07/31/21 09:19:06 HTTP/myhost.idm.example.com@IDM.EXAMPLE.COM
    07/30/21 09:19:06  07/31/21 09:19:06  krbtgt/IDM.EXAMPLE.COM@IDM.EXAMPLE.COM
            for client HTTP/myhost.idm.example.com@IDM.EXAMPLE.COM
  • 次の要件を満たすように Ansible コントロールノードを設定している。

    • Ansible バージョン 2.14 以降を使用している。
    • Ansible コントローラーに ansible-freeipa パッケージがインストールされている。
    • この例では、~/MyPlaybooks/ ディレクトリーに、IdM サーバーの完全修飾ドメイン名 (FQDN) を使用して Ansible インベントリーファイル を作成したことを前提としている。
    • この例では、secret.yml Ansible ボールトに ipaadmin_password が保存されていることを前提としている。

手順

  1. ~/MyPlaybooks/ ディレクトリーに移動します。

    $ cd ~/MyPlaybooks/
  2. 以下の内容で web-console-smart-card-ssh.yml Playbook を作成します。

    1. 委任対象の存在を確認するタスクを作成します。

      ---
      - 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
    2. 対象ホストを委任ターゲットに追加するタスクを追加します。

        - 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
    3. 委任ルールの存在を確認するタスクを追加します。

        - name: Ensure servicedelegationrule delegation-rule is present
          ipaservicedelegationrule:
            ipaadmin_password: "{{ ipaadmin_password }}"
            name: web-console-delegation-rule
    4. Web コンソールクライアントサービスの 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
    5. 制約付き委任ルールが 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: member
  3. ファイルを保存します。
  4. Ansible Playbook を実行します。Playbook ファイル、secret.yml ファイルを保護するパスワードを格納するファイル、およびインベントリーファイルを指定します。

    $ ansible-playbook --vault-password-file=password_file -v -i inventory web-console-smart-card-ssh.yml
  5. remote.idm.example.com で Kerberos 認証を有効にします。

    1. root として remote.idm.example.comSSH 接続します。
    2. /etc/ssh/sshd_config ファイルを開いて編集します。
    3. GSSAPIAuthentication no 行のコメントを外し、GSSAPIAuthentication yes に置き換えて、GSSAPIAuthentication を有効にします。

関連情報