36.3. Ansible을 사용하여 스마트 카드로 인증된 사용자가 다시 인증하지 않고 원격 호스트에 SSH로 SSH를 수행할 수 있도록 웹 콘솔을 구성
RHEL 웹 콘솔에서 사용자 계정에 로그인한 후 SSH 프로토콜을 사용하여 원격 머신에 연결할 수 있습니다. servicedelegationrule
및 servicedelegationtarget
모듈을 사용하여 제한된 위임 기능에 대한 웹 콘솔을 구성할 수 있으므로 다시 인증할 수 없습니다.
예제 절차에서 웹 콘솔 세션은 myhost.idm.example.com
호스트에서 실행되며 인증된 사용자를 대신하여 SSH를 사용하여 remote.idm.example.com
호스트에 액세스하도록 구성합니다.
사전 요구 사항
-
IdM
관리자
암호입니다. -
remote.idm.example.com
에 대한루트
액세스. - 웹 콘솔 서비스는 IdM에서 실행됩니다.
웹 콘솔에서 사용자 세션에서
S4U2Proxy
Kerberos 티켓을 생성했습니다. 이를 확인하려면 웹 콘솔에 IdM 사용자로 로그인하고터미널
페이지를 열고 다음을 입력합니다.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
패키지가 설치되어 있습니다. - 이 예제에서는 ~/MyPlaybook/ 디렉터리에서 IdM 서버의 FQDN(정규화된 도메인 이름)을 사용하여 Ansible 인벤토리 파일을 생성했다고 가정합니다.
-
이 예제에서는 secret.yml Ansible 자격 증명 모음이
ipaadmin_password
를 저장한다고 가정합니다.
-
ansible-freeipa
모듈이 실행되는 노드인 대상 노드는 IdM 도메인의 일부인 IdM 클라이언트, 서버 또는 복제본입니다.
절차
~/MyPlaybooks/ 디렉터리로 이동합니다.
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/
Copy to Clipboard Copied! 다음 콘텐츠를 사용하여
web-console-smart-card-ssh.yml
플레이북을 생성합니다.위임 대상의 존재를 확인하는 작업을 생성합니다.
--- - 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! 웹 콘솔 클라이언트 서비스의 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 플레이북을 실행합니다. 플레이북 파일을 지정하고
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 인증을 활성화합니다.-
SSH를 통해
root
로remote.idm.example.com
에 연결합니다. -
편집을 위해
/etc/ssh/sshd_config
파일을 엽니다. -
GSSAPIAuthentication
noGSSAPIAuthentication yes
로 교체하여 GSSAPIAuthentication을 활성화합니다.
-
SSH를 통해
remote.idm.example.com
에서sshd
서비스를 다시 시작하여 변경 사항이 즉시 적용됩니다.systemctl try-restart sshd.service
$ systemctl try-restart sshd.service
Copy to Clipboard Copied!