Chapter 15. Exploring RHEL Identity Management in a controlled environment
15.1. Accessing the IdM Web UI in a PoC setup Copy linkLink copied to clipboard!
Learn how to log in to the IdM Web UI with a password for the first time.
Procedure
Type the URL of the IdM server or replica into the browser address bar:
https://replica.idm.example.com
https://replica.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow This opens the IdM Web UI login screen in your browser.
On the Web UI login screen, enter the
adminin to the Login field. EnterSecret123in to the Password field.
Click .
After the successful login, you can start configuring the IdM server.
15.2. Adding an IdM user using the IdM Web UI in the PoC setup Copy linkLink copied to clipboard!
Learn how to use the IdM Web UI to add an IdM user and set the IdM user password.
Procedure
-
Log in to the IdM Web UI as IdM
admin. For details, see Accessing the IdM Web UI in a PoC setup. -
Go to Users
Active Users tab. - Click the + Add icon.
Optional: In the User login field, add a login name, for example
idmuser01.If you leave it empty, the IdM server creates the login name in the following pattern: The first letter of the first name and the surname. The whole login name can have up to 32 characters.
-
Enter First name and Last name of the new user, for example
AliceandAcme. Optional: In the Password and Verify password fields, enter the user password and confirm it, ensuring they both match.
This is an initial, temporary password. The user will be asked to reset the password at the first login.
Click the Add button.
At this point, you can see the user account in the Active Users table.
If you click on the user name, you can edit advanced settings, such as adding a phone number, address, or occupation.
15.3. Adding multiple IdM users by using an Ansible playbook in a PoC setup Copy linkLink copied to clipboard!
Automating user management with Ansible is more efficient than using the Web UI approach described in Adding an IdM user using an Ansible playbook in a PoC setup.
Learn how to use a single Ansible playbook to add multiple IdM users. Because of Ansible idempotence, if any of the users already exists in IdM, the script skips them.
Prerequisites
- You are logged in to controller.idm.example.com as the ansible user.
Procedure
In your ~/MyPlaybooks directory, create an add-multiple-users.yml Ansible playbook file with the data of the users whose presence you want to ensure in IdM, for example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must use the following options to add a user:
- name: the login name
- first: the first name string
- last: the last name string
The rest is optional.
You can see the full list of available user options in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/README-user.mdMarkdown file.[Optional] Clear the SSSD cache to improve the performance of the
ansible-playbookcommand:sudo sss_cache -E
$ sudo sss_cache -ECopy to Clipboard Copied! Toggle word wrap Toggle overflow [sudo] password for ansible:
[sudo] password for ansible:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the playbook:
ansible-playbook -i inventory add-multiple-users.yml
$ ansible-playbook -i inventory add-multiple-users.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Next steps
Log into the IdM Web UI as
idmuser01:- Use "Password123", the temporary password configured by the Ansible script above, as idmuser01 password.
- Set a new password.
-
Repeat for
idmuser03.
15.4. Host-based access control rules in IdM Copy linkLink copied to clipboard!
Host-based access control (HBAC) rules define which users or user groups can access which hosts or host groups by using which services or services in a service group. As a system administrator, you can use HBAC rules to achieve the following goals:
- Limit access to a specified system in your domain to members of a specific user group.
- Allow only a specific service to be used to access systems in your domain.
By default, IdM is configured with a default HBAC rule named allow_all, which means universal access to every host for every user via every relevant service in the entire IdM domain.
You can fine-tune access to different hosts by replacing the default allow_all rule with your own set of HBAC rules. For centralized and simplified access control management, you can apply HBAC rules to user groups, host groups, or service groups instead of individual users, hosts, or services.
15.5. Using the IdM Web UI to enable an IdM user to access an IdM client remotely in a PoC setup Copy linkLink copied to clipboard!
Learn how to use the Identity Management (IdM) Web UI to define a host-based access rule (HBAC) rule to allow a set of RHEL IdM users to access IdM clients using the SSH protocol. The example below describes how to:
-
Enable the IdM user
idmuser01to access an IdM clientclient.idm.example.comremotely by using theSSHprotocol. -
Disable the IdM user
idmuser03from using theSSHprotocol to access the IdM clientclient.idm.example.com.
Prerequisites
- The idmuser01 and idmuser03 users exist in IdM. See Adding an IdM user using the IdM Web UI in the PoC setup for details.
- The client.idm.example.com host exists in IdM. See
-
You are logged in to the IdM Web UI as IdM
admin.
Procedure
Create and customize the
allow_remote_accessrule:-
Navigate to Policy > Host Based Access Control > HBAC Rules and then click Add. Set
allow_remote_accessas the name of the rule and click Add and Edit. -
In the Who section, verify that Specified Users and Groups is selected, and then click Add. Select the
idmuser01user, and then click>to move the user to the Prospective column. Click Add. -
In the Accessing section, verify that Specified Hosts and Groups is selected, and then click Add. Select the
client.idm.example.commachine and click>to move it to the Prospective column. Click Add. -
In the Via Service section, verify that Specified Services and Groups is selected, and then click Add. Select the
ftp,sshd, andvsftpdservices from the Available column and click>to move them to the Prospective column. Click Add. - Return to the HBAC rules list by clicking HBAC Rules at the top of the window.
-
Navigate to Policy > Host Based Access Control > HBAC Rules and then click Add. Set
For security reasons, modify the
allow_allrule so that only IdMadminshave universal access to every host via every relevant service in the entire IdM domain:- Navigate to Policy > Host Based Access Control > HBAC Rules.
-
Click the
allow_allrule. -
In the Who section, verify that Specified Users and Groups is selected, and then click Add. Select the
adminsgroup, and then click>to move it to the Prospective column. Click Add.
Verification
Navigate to Policy > Host Based Access Control > HBAC Test. Select the parameters of the test according to the following table:
Expand List Select WHO
idmuser03
ACCESSING
client.idm.example.com
VIA SERVICE
sshd
RULES
allow_remote_access
-
On the Run Test tab, click Run Test to run the simulation. On the right side of the Run Test tab, the console shows an ACCESS DENIED message because the
idmuser03user is not a member of the HBAC rule. Now select the test parameters according to the following table:
Expand List Select WHO
idmuser01
ACCESSING
client.idm.example.com
VIA SERVICE
sshd
RULES
allow_remote_access
-
On the Run Test tab, click Run Test to run the simulation. On the right side of the Run Test tab, the console shows an ACCESS GRANTED message because the
idmuser01user is a member of the HBAC rule. Open a terminal and log in to the client machine as the
idmuser03user. The connection fails because the user is not a member of the rule:ssh idmuser03@client
$ ssh idmuser03@client Connection closed by 172.25.250.11 port 22Copy to Clipboard Copied! Toggle word wrap Toggle overflow Try to log in to the client machine as the
idmuser01user. The connection is successful because the user is a member of the rule:ssh idmuser01@client
$ ssh idmuser01@client ...output omitted... [idmuser01@client /]$*Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.6. Using Ansible to enable an IdM user to access an IdM client remotely in a PoC setup Copy linkLink copied to clipboard!
Automating host-based access control configuration with Ansible is more efficient than using the Web UI approach described in Enabling an IdM user to manage IdM groups and group membership using the IdM Web UI in the PoC setup.
Learn how to ensure the presence of a host-based access control (HBAC) rule in Identity Management (IdM) using an Ansible playbook. The example below describes how to:
-
Enable the IdM user
idmuser01to access an IdM clientclient.idm.example.comremotely by using theSSHprotocol. -
Disable the IdM user
idmuser03from using theSSHprotocol to access the IdM clientclient.idm.example.com.
Prerequisites
- The idmuser01 and idmuser03 users exist in IdM. See Adding an IdM user using the IdM Web UI in the PoC setup for details.
- You are logged in to controller.idm.example.com as the ansible user.
Procedure
In your ~/MyPlaybooks/ directory, create an
ensure-new-hbacrule-present.ymlAnsible playbook file with the content below that defines the desired HBAC policy:Copy to Clipboard Copied! Toggle word wrap Toggle overflow If an HBAC rule already exists and you are only modifying it, you must set the
actionoption tomember. Otherwise the playbook fails. In the example, theEnsure allow_all rule is modified so that only admins are memberstask modifies theallow_allbuilt-in rule, and therefore, requiresaction: member.TipTo avoid writing your HBAC-related playbooks from scratch, you can copy and modify the sample playbooks in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/hbacrule/directory.Run the playbook:
ansible-playbook -i inventory ensure-new-hbacrule-present.yml
$ ansible-playbook -i inventory ensure-new-hbacrule-present.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Navigate to Policy > Host Based Access Control > HBAC Test. Select the parameters of the test according to the following table:
Expand List Select WHO
idmuser03
ACCESSING
client.idm.example.com
VIA SERVICE
sshd
RULES
allow_remote_access
-
On the Run Test tab, click Run Test to run the simulation. On the right side of the Run Test tab, the console shows an ACCESS DENIED message because the
idmuser03user is not a member of the HBAC rule. Now select the test parameters according to the following table:
Expand List Select WHO
idmuser01
ACCESSING
client.idm.example.com
VIA SERVICE
sshd
RULES
allow_remote_access
-
On the Run Test tab, click Run Test to run the simulation. On the right side of the Run Test tab, the console shows an ACCESS GRANTED message because the
idmuser01user is a member of the HBAC rule. Open a terminal and log in to the client machine as the
idmuser03user. The connection fails because the user is not a member of the rule:ssh idmuser03@client
$ ssh idmuser03@client (idmuser03@client) Password: RedHat123& Connection closed by 172.25.250.11 port 22Copy to Clipboard Copied! Toggle word wrap Toggle overflow Try to log in to the client machine as the
idmuser01user. The connection is successful because the user is a member of the rule:ssh idmuser01@client
$ ssh idmuser01@client (idmuser01@client) Password: Password123 ...output omitted... [idmuser01@client /]$*Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.7. Role-based access control in RHEL IdM Copy linkLink copied to clipboard!
Learn more about role-based access control (RBAC) in Identity Management (IdM). RBAC is a security feature that restricts access to authorized users. You can define roles with specific permissions and then assign those roles to users.
Role-based access control is composed of three parts:
- Permissions grant the right to perform a specific task such as adding or deleting users, modifying a group, and enabling read-access.
- Privileges combine permissions, for example all the permissions needed to add a new user.
- Roles grant a set of privileges to users, user groups, hosts or host groups.
15.8. Enabling an IdM user to manage IdM groups and group membership using the IdM Web UI in the PoC setup Copy linkLink copied to clipboard!
The built-in Group Administrators privilege in RHEL Identity Management (IdM) contains the following permissions:
- Add Groups
- Modify External Group Membership
- Modify Group Membership
- Modify Groups
- Remove Groups
Learn how to use the IdM Web UI to assign a role that grants the Group Administrator privilege to the IdM user idmuser01. As a result, idmuser01 can add the idmuser03 to the built-in editors group.
Prerequisites
- The idmuser01 and idmuser03 IdM users exist. See Adding an IdM user using the IdM Web UI in the PoC setup for details.
Procedure
-
Log in as IdM
adminto the IdM Web UI. Create the
groupadminrole:- Navigate to IPA Server > Role-Based Access Control > Roles and then click Add.
- In the Role name field, enter groupadmin. In the Description field, enter Group Administrator. Click Add and Edit.
Add the
idmuser01user to the role:- On the Role: groupadmin page, ensure that you are on the Users tab, and click Add.
-
In the Add users into role 'groupadmin' window, check the box next to
idmuser01and click > to move the user from the Available to the Prospective column. - Click Add.
Add the
Group Administratorsprivilege to the role:- On the Role: groupadmin page, ensure that you are on the Privileges tab, and click Add.
- In the Add role 'groupadmin' into privileges window, check the box next to Group Administrators and click > to move the user from the Available to the Prospective column.
- Click Add.
Verification
Verify that
idmuser01is assigned to thegroupadminrole:-
In the IdM Web UI, navigate as IdM
adminto Identity > Users. -
Click
idmuser01. Click Roles.
You can see that
groupadminis listed among the roles.
-
In the IdM Web UI, navigate as IdM
Verify that
idmuser01can assign group membership toidmuser03:-
Log in to the IdM Web UI as
idmuser01. - Navigate to Identity > Users.
-
Click
idmuser03. - Click User Groups.
- Click Add.
Select the
editorsgroup and then click>to move it to the Prospective column. Click Add.In the user profile, you can now see that
idmuser03is a member of theeditorsgroup.
-
Log in to the IdM Web UI as
Additional resources
15.9. Enabling an IdM user to manage IdM groups and group membership using an Ansible playbook in the PoC setup Copy linkLink copied to clipboard!
Automating role-based access control configuration with Ansible is more efficient than using the Web UI approach described in Enabling an IdM user to manage IdM groups and group membership using the IdM Web UI in the PoC setup.
Learn how to use the role ansible-freeipa module in an Ansible playbook to assign a role that grants the IdM user idmuser01 the same Group Administrator privilege as configured using the Web UI method. As a result, idmuser01 can add the idmuser03 to the built-in editors group.
Prerequisites
- The idmuser01 and idmuser03 IdM users exist. See Adding an IdM user using the IdM Web UI in the PoC setup for details.
- You are logged in to controller.idm.example.com as the ansible user.
Procedure
In your ~/MyPlaybooks/ directory, create an assign-group-administrator-privilege-to-idmuser01.yml Ansible playbook file with the content below that defines the desired RBAC policy:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can see the full list of available options in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/README-role.mdfile.Run the playbook:
ansible-playbook -i inventory assign-group-administrator-privilege-to-idmuser01.yml
$ ansible-playbook -i inventory assign-group-administrator-privilege-to-idmuser01.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that
idmuser01is assigned to thegroupadminrole:-
In the IdM Web UI, navigate as IdM
adminto Identity > Users. -
Click
idmuser01. Click Roles.
You can see that
groupadminis listed among the roles.
-
In the IdM Web UI, navigate as IdM
Verify that
idmuser01can assign group membership toidmuser03:-
Log in to the IdM Web UI as
idmuser01. - Navigate to Identity > Users.
-
Click
idmuser03. - Click User Groups.
- Click Add.
Select the
editorsgroup and then click>to move it to the Prospective column. Click Add.In the user profile, you can now see that
idmuser03is a member of theeditorsgroup.
-
Log in to the IdM Web UI as
15.10. Sudo access on an IdM client Copy linkLink copied to clipboard!
System administrators can grant sudo access to allow non-root users to execute administrative commands that are normally reserved for the root user. Consequently, when users need to perform an administrative command normally reserved for the root user, they precede that command with sudo. After entering their password, the command is executed as if they were the root user. To execute a sudo command as another user or group, such as a database service account, you can configure a RunAs alias for a sudo rule.
If a Red Hat Enterprise Linux (RHEL) host is enrolled as an Identity Management (IdM) client, you can specify sudo rules defining which IdM users can perform which commands on the host in the following ways:
-
Locally in the
/etc/sudoersfile - Centrally in IdM
You can create a central sudo rule for an IdM client using the command line (CLI) and the IdM Web UI.
You can also configure password-less authentication for sudo using the Generic Security Service Application Programming Interface (GSSAPI), the native way for UNIX-based operating systems to access and authenticate Kerberos services. You can use the pam_sss_gss.so Pluggable Authentication Module (PAM) to invoke GSSAPI authentication via the SSSD service, allowing users to authenticate to the sudo command with a valid Kerberos ticket.
15.11. Granting sudo access to an IdM user on an IdM client using the IdM Web UI Copy linkLink copied to clipboard!
In Identity Management (IdM), you can grant sudo access for a specific command to an IdM user account on a specific IdM host. First, add a sudo command and then create a sudo rule for one or more commands.
Complete this procedure to create the idmuser01_reboot sudo rule to grant the idmuser01 account the permission to run the /usr/sbin/reboot command on the client.idm.example.com machine, or client.
Prerequisites
-
You are logged in to the IdM Web UI as
admin. -
You have created a user account for
idmuser01in IdM and unlocked the account by creating a password for the user. For details on adding a new IdM user using the command line, see Adding users using the command line. -
No local
idmuser01account is present on theclienthost. Theidmuser01user is not listed in the local/etc/passwdfile. - The client.idm.example.com host exists in IdM.
Procedure
Add the
/usr/sbin/rebootcommand to the IdM database ofsudocommands:-
Navigate to Policy
Sudo Sudo Commands. - Click Add in the upper right corner to open the Add sudo command dialog box.
Enter the command you want the user to be able to perform using
sudo:/usr/sbin/reboot.- Click Add.
-
Navigate to Policy
Use the new
sudocommand entry to create a sudo rule to allow idmuser01 to reboot the client machine:-
Navigate to Policy
Sudo Sudo rules. - Click Add in the upper right corner to open the Add sudo rule dialog box.
-
Enter the name of the
sudorule: idmuser01_reboot. - Click Add and Edit.
Specify the user:
- In the Who section, check the Specified Users and Groups radio button.
- In the User category the rule applies to subsection, click Add to open the Add users into sudo rule "idmuser01_reboot" dialog box.
- In the Add users into sudo rule "idmuser01_reboot" dialog box in the Available column, check the idmuser01 checkbox, and move it to the Prospective column.
- Click Add.
Specify the host:
- In the Access this host section, check the Specified Hosts and Groups radio button.
- In the Host category this rule applies to subsection, click Add to open the Add hosts into sudo rule "idmuser01_reboot" dialog box.
- In the Add hosts into sudo rule "idmuser01_reboot" dialog box in the Available column, check the client.idm.example.com checkbox, and move it to the Prospective column.
- Click Add.
Specify the commands:
- In the Command category the rule applies to subsection of the Run Commands section, check the Specified Commands and Groups radio button.
- In the Sudo Allow Commands subsection, click Add to open the Add allow sudo commands into sudo rule "idmuser01_reboot" dialog box.
-
In the Add allow sudo commands into sudo rule "idmuser01_reboot" dialog box in the Available column, check the
/usr/sbin/rebootcheckbox, and move it to the Prospective column. - Click Add to return to the idm_sudo_reboot page.
Figure 15.1. Adding IdM sudo rule
Click Save in the top left corner.
The new rule is enabled by default.
NotePropagating the changes from the server to the client can take a few minutes.
-
Navigate to Policy
Verification
-
Log in to
clientasidmuser01. Reboot the machine using
sudo. Enter the password foridmuser01when prompted:sudo /usr/sbin/reboot
$ sudo /usr/sbin/reboot [sudo] password for idmuser01:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If the sudo rule is configured correctly, the machine reboots.
15.12. Granting sudo access to an IdM user on an IdM client using an Ansible playbook in a PoC setup Copy linkLink copied to clipboard!
Learn how to use a single Ansible playbook to grant sudo access for a specific command to an IdM user account on a specific IdM host.First, add a sudo command and then create a sudo rule for one or more commands.
Complete this procedure to create the idmuser01_reboot sudo rule to grant the idmuser01 account the permission to run the /usr/sbin/reboot command on the client.idm.example.com machine, or client.
Prerequisites
- You are logged in to controller.idm.example.com as the ansible user.
Procedure
In your ~/MyPlaybooks directory, create an add-sudo-rule.yml Ansible playbook file with the parameters of the
sudorule, for example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow If a
sudorule already exists and you are only modifying it, you must set theactionoption tomember. Otherwise the playbook fails. In the example, theModify the idmuser01_reboot sudo rule by adding reboot command and idmuser01task modifies the rule that theCreate a sudo rule idmuser01_reboottask created previously, and therefore, requiresaction: member.You can see the full list of available options in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/README-sudocmd.mdand…/README-sudorule.mdfiles.Run the playbook:
ansible-playbook -i inventory add-sudo-rule.yml
$ ansible-playbook -i inventory add-sudo-rule.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
-
Log in to
clientasidmuser01. Reboot the machine using
sudo. Enter the password foridmuser01when prompted:sudo /usr/sbin/reboot
$ sudo /usr/sbin/reboot [sudo] password for idmuser01:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If the sudo rule is configured correctly, the machine reboots.