Este conteúdo não está disponível no idioma selecionado.
Chapter 53. Using constrained delegation in IdM
The constrained delegation enables one service to access other services on your behalf. You grant only limited authority for one service instead of giving full access to all your credentials.
53.1. Constrained delegation in Identity Management Copiar o linkLink copiado para a área de transferência!
The Service for User to Proxy (S4U2proxy) extension provides a service that obtains a service ticket to another service on behalf of a user. This feature is known as constrained delegation. The second service is typically a proxy performing some work on behalf of the first service, under the authorization context of the user. Using constrained delegation eliminates the need for the user to delegate their full ticket-granting ticket (TGT).
Identity Management (IdM) traditionally uses the Kerberos S4U2proxy feature to allow the web server framework to obtain an LDAP service ticket on the user’s behalf. The IdM-AD trust system also uses constrained delegation to obtain a cifs principal.
You can use the S4U2proxy feature to configure a web console client to allow an IdM user that has authenticated with a smart card to achieve the following:
- Run commands with superuser privileges on the RHEL host on which the web console service is running without being asked to authenticate again.
-
Access a remote host using
SSHand access services on the host without being asked to authenticate again.
53.2. Configuring smart-card authentication for SSH logins in the web console Copiar o linkLink copiado para a área de transferência!
After logging in to a user account on the RHEL web console, you can connect to remote machines by using the SSH protocol. You can use the constrained delegation feature to use SSH without being asked to authenticate again.
In the example procedure, the web console session runs on the myhost.idm.example.com host, and you configure the console to access the remote.idm.example.com host by using SSH on behalf of the authenticated user.
Prerequisites
-
You have obtained an IdM
adminticket-granting ticket (TGT) onmyhost.idm.example.com. -
You have
rootaccess toremote.idm.example.com. - The host that runs the web console is a member of an IdM domain.
Procedure
In the Terminal page, verify that the web console has created a Service for User to Proxy (S4U2proxy) Kerberos ticket in the user session:
klist
$ 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 …Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a list of the target hosts that the delegation rule can access:
Create a service delegation target:
ipa servicedelegationtarget-add cockpit-target
$ ipa servicedelegationtarget-add cockpit-targetCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the target host to the delegation target:
ipa servicedelegationtarget-add-member cockpit-target \ --principals=host/remote.idm.example.com@IDM.EXAMPLE.COM
$ ipa servicedelegationtarget-add-member cockpit-target \ --principals=host/remote.idm.example.com@IDM.EXAMPLE.COMCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Allow
cockpitsessions to access the target host list by creating a service delegation rule and adding the HTTP service Kerberos principal to it:Create a service delegation rule:
ipa servicedelegationrule-add cockpit-delegation
$ ipa servicedelegationrule-add cockpit-delegationCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the web console client to the delegation rule:
ipa servicedelegationrule-add-member cockpit-delegation \ --principals=HTTP/myhost.idm.example.com@IDM.EXAMPLE.COM
$ ipa servicedelegationrule-add-member cockpit-delegation \ --principals=HTTP/myhost.idm.example.com@IDM.EXAMPLE.COMCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the delegation target to the delegation rule:
ipa servicedelegationrule-add-target cockpit-delegation \ --servicedelegationtargets=cockpit-target
$ ipa servicedelegationrule-add-target cockpit-delegation \ --servicedelegationtargets=cockpit-targetCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Enable Kerberos authentication on the
remote.idm.example.comhost:-
Connect through SSH to
remote.idm.example.comasroot. -
Add the
GSSAPIAuthentication yesline to the/etc/ssh/sshd_configfile.
-
Connect through SSH to
Restart the
sshdservice onremote.idm.example.comso that the changes take effect immediately:systemctl try-restart sshd.service
$ systemctl try-restart sshd.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
53.3. Using Ansible to configure smart-card authentication for SSH logins in the web console Copiar o linkLink copiado para a área de transferência!
After logging in to a user account on the RHEL web console, you can connect to remote machines by using the SSH protocol. You can use the servicedelegationrule and servicedelegationtarget Ansible modules to configure the web console for the constrained delegation feature, which enables SSH connections without being asked to authenticate again.
In the example procedure, the web console session runs on the myhost.idm.example.com host and you configure it to access the remote.idm.example.com host by using SSH on behalf of the authenticated user.
Prerequisites
-
You have obtained an IdM
adminticket-granting ticket (TGT) onmyhost.idm.example.com. -
You have
rootaccess toremote.idm.example.com. - The host that runs the web console is a member of an IdM domain.
You have configured your Ansible control node to meet the following requirements:
-
You have installed the
ansible-freeipapackage. -
The example assumes you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server in the
~/MyPlaybooks/directory. -
The example assumes that the
secret.ymlAnsible vault stores the admin password in theipaadmin_passwordvariable.
-
You have installed the
-
The target node, that is the node on which the
ansible-freeipamodule runs, is part of the IdM domain as an IdM client, server, or replica.
Procedure
Navigate to your
~/MyPlaybooks/directory:cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Store your sensitive variables in an encrypted file:
Create the vault:
ansible-vault create secret.yml
$ ansible-vault create secret.yml New Vault password: <vault_password> Confirm New Vault password: <vault_password>Copy to Clipboard Copied! Toggle word wrap Toggle overflow After the
ansible-vault createcommand opens an editor, enter the sensitive data in the<key>: <value>format:ipaadmin_password: <admin_password>
ipaadmin_password: <admin_password>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the changes, and close the editor. Ansible encrypts the data in the vault.
In the Terminal page, verify that the web console has created a Service for User to Proxy (S4U2proxy) Kerberos ticket in the user session:
klist
$ 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 …Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
web-console-smart-card-ssh.ymlplaybook with the following content:Create a task that ensures the presence of a delegation target:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a task that adds the target host to the delegation target:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a task that ensures the presence of a delegation rule:
- 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-ruleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add a task that ensures that the Kerberos principal of the web console client service is a member of the constrained delegation rule:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a task that ensures that the constrained delegation rule is associated with the web-console-delegation-target delegation target:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a task that enable Kerberos authentication on
remote.idm.example.com:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Save the file.
Run the Ansible playbook. Specify the playbook file, the file storing the password protecting the
secret.ymlfile, and the inventory file: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.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
53.4. Configuring a web console to allow a user authenticated with a smart card to run sudo without being asked to authenticate again Copiar o linkLink copiado para a área de transferência!
After you have logged in to a user account on the RHEL web console, as an Identity Management (IdM) system administrator you might need to run commands with superuser privileges. You can use the constrained delegation feature to run sudo on the system without being asked to authenticate again.
Follow this procedure to configure a web console to use constrained delegation. In the example below, the web console session runs on the myhost.idm.example.com host.
Prerequisites
-
You have obtained an IdM
adminticket-granting ticket (TGT). - The web console service is present in IdM.
- The myhost.idm.example.com host is present in IdM.
-
You have enabled
adminsudoaccess to domain administrators on the IdM server. The web console has created an
S4U2ProxyKerberos ticket in the user session. To verify that this is the case, log in to the web console as an IdM user, open theTerminalpage, and enter:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Create a list of the target hosts that can be accessed by the delegation rule:
Create a service delegation target:
ipa servicedelegationtarget-add cockpit-target
$ ipa servicedelegationtarget-add cockpit-targetCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the target host to the delegation target:
ipa servicedelegationtarget-add-member cockpit-target \ --principals=host/myhost.idm.example.com@IDM.EXAMPLE.COM
$ ipa servicedelegationtarget-add-member cockpit-target \ --principals=host/myhost.idm.example.com@IDM.EXAMPLE.COMCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Allow
cockpitsessions to access the target host list by creating a service delegation rule and adding theHTTPservice Kerberos principal to it:Create a service delegation rule:
ipa servicedelegationrule-add cockpit-delegation
$ ipa servicedelegationrule-add cockpit-delegationCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the web console service to the delegation rule:
ipa servicedelegationrule-add-member cockpit-delegation \ --principals=HTTP/myhost.idm.example.com@IDM.EXAMPLE.COM
$ ipa servicedelegationrule-add-member cockpit-delegation \ --principals=HTTP/myhost.idm.example.com@IDM.EXAMPLE.COMCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the delegation target to the delegation rule:
ipa servicedelegationrule-add-target cockpit-delegation \ --servicedelegationtargets=cockpit-target
$ ipa servicedelegationrule-add-target cockpit-delegation \ --servicedelegationtargets=cockpit-targetCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Enable
pam_sss_gss, the PAM module for authenticating users over the Generic Security Service Application Program Interface (GSSAPI) in cooperation with the System Security Services Daemon (SSSD):-
Open the
/etc/sssd/sssd.conffile for editing. Specify that
pam_sss_gsscan provide authentication for thesudoandsudo -icommands in IdM your domain:[domain/idm.example.com] pam_gssapi_services = sudo, sudo-i
[domain/idm.example.com] pam_gssapi_services = sudo, sudo-iCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Save and exit the file.
-
Open the
/etc/pam.d/sudofile for editing. Insert the following line to the top of the
#%PAM-1.0list to allow, but not require, GSSAPI authentication forsudocommands:auth sufficient pam_sss_gss.so
auth sufficient pam_sss_gss.soCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Save and exit the file.
-
Open the
Restart the
SSSDservice so that the above changes take effect immediately:systemctl restart sssd
$ systemctl restart sssdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
53.5. Using Ansible to configure a web console to allow a user authenticated with a smart card to run sudo without being asked to authenticate again Copiar o linkLink copiado para a área de transferência!
After you have logged in to a user account on the RHEL web console, as an Identity Management (IdM) system administrator you might need to run commands with superuser privileges. You can use the constrained delegation feature to run sudo on the system without being asked to authenticate again.
Follow this procedure to use the ipaservicedelegationrule and ipaservicedelegationtarget ansible-freeipa modules to configure a web console to use constrained delegation. In the example below, the web console session runs on the myhost.idm.example.com host.
Prerequisites
-
You have obtained an IdM
adminticket-granting ticket (TGT) by authenticating to the web console session with a smart card.. - The web console service has been enrolled into IdM.
- The myhost.idm.example.com host is present in IdM.
-
You have enabled
adminsudoaccess to domain administrators on the IdM server. The web console has created an
S4U2ProxyKerberos ticket in the user session. To verify that this is the case, log in to the web console as an IdM user, open theTerminalpage, and enter:Copy to Clipboard Copied! Toggle word wrap Toggle overflow You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.15 or later.
-
You have installed the
freeipa.ansible_freeipacollection. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_passwordand that you have access to a file that stores the password protecting the secret.yml file.
-
The target node, that is the node on which the
freeipa.ansible_freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica.
Procedure
On your Ansible control node, navigate to your ~/MyPlaybooks/ directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
web-console-smart-card-sudo.ymlplaybook with the following content:Create a task that ensures the presence of a delegation target:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a task that adds the target host to the delegation target:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a task that ensures the presence of a delegation rule:
- name: Ensure servicedelegationrule named sudo-web-console-delegation-rule is present freeipa.ansible_freeipa.ipaservicedelegationrule: ipaadmin_password: "{{ ipaadmin_password }}" name: sudo-web-console-delegation-rule- name: Ensure servicedelegationrule named sudo-web-console-delegation-rule is present freeipa.ansible_freeipa.ipaservicedelegationrule: ipaadmin_password: "{{ ipaadmin_password }}" name: sudo-web-console-delegation-ruleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add a task that ensures that the Kerberos principal of the web console service is a member of the constrained delegation rule:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a task that ensures that the constrained delegation rule is associated with the sudo-web-console-delegation-target delegation target:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Save the file.
For details about variables and example playbooks in the FreeIPA Ansible collection, see the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/README-servicedelegationrule.mdfile and the/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/servicedelegationtargetdirectory on the control node.Run the Ansible playbook. Specify the playbook file, the file storing the password protecting the secret.yml file, and the inventory file:
ansible-playbook --vault-password-file=password_file -v -i inventory web-console-smart-card-sudo.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory web-console-smart-card-sudo.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable
pam_sss_gss, the PAM module for authenticating users over the Generic Security Service Application Program Interface (GSSAPI) in cooperation with the System Security Services Daemon (SSSD):-
Open the
/etc/sssd/sssd.conffile for editing. Specify that
pam_sss_gsscan provide authentication for thesudoandsudo -icommands in IdM your domain:[domain/idm.example.com] pam_gssapi_services = sudo, sudo-i
[domain/idm.example.com] pam_gssapi_services = sudo, sudo-iCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Save and exit the file.
-
Open the
/etc/pam.d/sudofile for editing. Insert the following line to the top of the
#%PAM-1.0list to allow, but not require, GSSAPI authentication forsudocommands:auth sufficient pam_sss_gss.so
auth sufficient pam_sss_gss.soCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Save and exit the file.
-
Open the
Restart the
SSSDservice so that the above changes take effect immediately:systemctl restart sssd
$ systemctl restart sssdCopy to Clipboard Copied! Toggle word wrap Toggle overflow