36.3. Ansible を使用して Web コンソールを設定し、スマートカードで認証されたユーザーが再認証を求められることなくリモートホストに SSH 接続できるようにする
RHEL Web コンソールでユーザーアカウントにログインした後、SSH プロトコルを使用してリモートマシンに接続できます。servicedelegationrule
および servicedelegationtarget
モジュールを使用して、制約付き委任機能用に Web コンソールを設定できます。これにより、再度認証を求められることなく SSH 接続が可能になります。
この手順例では、Web コンソールセッションが myhost.idm.example.com
ホストで実行され、認証されたユーザーの代わりに SSH を使用して remote.idm.example.com
ホストにアクセスするように設定します。
前提条件
-
IdM
admin
パスワードがある -
remote.idm.example.com
へのroot
アクセスがある - Web コンソールサービスは IdM で実行されます。
Web コンソールは、ユーザーセッションに
S4U2Proxy
Kerberos チケットを作成している。確認するには、IdM ユーザーとして Web コンソールにログインし、Terminal
ページを開き、次のように入力します。klist
$ 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
Copy to Clipboard Copied! 次の要件を満たすように Ansible コントロールノードを設定した。
- Ansible バージョン 2.14 以降を使用している。
-
ansible-freeipa
パッケージがインストールされている。 - ~/MyPlaybooks/ ディレクトリーに、IdM サーバーの完全修飾ドメイン名 (FQDN) を使用して Ansible インベントリーファイル を作成している (この例の場合)。
-
この例では、secret.yml Ansible Vault に
ipaadmin_password
が保存されていることを前提としています。
-
ターゲットノード (
ansible-freeipa
モジュールが実行されるノード) が、IdM クライアント、サーバー、またはレプリカとして IdM ドメインに含まれている。
手順
~/MyPlaybooks/ ディレクトリーに移動します。
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/
Copy to Clipboard Copied! 以下の内容で
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: 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
Copy to Clipboard Copied! 対象ホストを委任ターゲットに追加するタスクを追加します。
- 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 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
Copy to Clipboard Copied! 委任ルールの存在を確認するタスクを追加します。
- name: Ensure servicedelegationrule delegation-rule is present ipaservicedelegationrule: ipaadmin_password: "{{ ipaadmin_password }}" name: web-console-delegation-rule
- name: Ensure servicedelegationrule delegation-rule is present ipaservicedelegationrule: ipaadmin_password: "{{ ipaadmin_password }}" name: web-console-delegation-rule
Copy to Clipboard Copied! 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
- 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
Copy to Clipboard Copied! 制約付き委任ルールが 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
- 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
Copy to Clipboard Copied!
- ファイルを保存します。
Ansible Playbook を実行します。Playbook ファイル、
secret.yml
ファイルを保護するパスワードを格納するファイル、およびインベントリーファイルを指定します。ansible-playbook --vault-password-file=password_file -v -i inventory web-console-smart-card-ssh.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory web-console-smart-card-ssh.yml
Copy to Clipboard Copied! remote.idm.example.com で
Kerberos 認証を有効にします。-
root
として、SSH 経由でremote.idm.example.com
に接続します。 -
/etc/ssh/sshd_config
ファイルを開いて編集します。 -
GSSAPIAuthentication no
行のコメントを外し、GSSAPIAuthentication yes
に置き換えて、GSSAPIAuthentication
を有効にします。
-
変更をすぐに有効にするには、
remote.idm.example.com
でsshd
サービスを再起動します。systemctl try-restart sshd.service
$ systemctl try-restart sshd.service
Copy to Clipboard Copied!