6.5. 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-freeipa
パッケージがインストールされている。 - ~/MyPlaybooks/ ディレクトリーに、IdM サーバーの完全修飾ドメイン名 (FQDN) を使用して Ansible インベントリーファイル を作成している (この例の場合)。
-
この例では、secret.yml Ansible Vault に
ipaadmin_password
が保存されていることを前提としています。
-
ターゲットノード (
ansible-freeipa
モジュールが実行されるノード) が、IdM クライアント、サーバー、またはレプリカとして IdM ドメインに含まれている。
手順
~/MyPlaybooks/ ディレクトリーに移動します。
$ cd ~/MyPlaybooks/
以下の内容で
web-console-smart-card-ssh.yml
Playbook を作成します。委任対象の存在を確認するタスクを作成します。
--- - 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-rule
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
制約付き委任ルールが 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
- ファイルを保存します。
Ansible Playbook を実行します。Playbook ファイル、secret.yml ファイルを保護するパスワードを格納するファイル、およびインベントリーファイルを指定します。
$ ansible-playbook --vault-password-file=password_file -v -i inventory web-console-smart-card-ssh.yml
remote.idm.example.com で Kerberos 認証を有効にします。
-
root
として remote.idm.example.com にSSH
接続します。 -
/etc/ssh/sshd_config
ファイルを開いて編集します。 -
GSSAPIAuthentication no
行のコメントを外し、GSSAPIAuthentication yes
に置き換えて、GSSAPIAuthentication
を有効にします。
-
関連情報
- スマートカードを使用して Web コンソールへのログイン
- アイデンティティー管理における制約付き委任
-
/usr/share/doc/ansible-freeipa/
ディレクトリーのREADME-servicedelegationrule.md
およびREADME-servicedelegationtarget.md
-
/usr/share/doc/ansible-freeipa/playbooks/servicedelegationtarget
および/usr/share/doc/ansible-freeipa/playbooks/servicedelegationrule
ディレクトリーのサンプル Playbook