Configure role-based, host-based, and sudo access control rules and assign accounts to use the rules.
Outcomes
Configure host-based access control.
Configure Sudo access rules.
As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available:
[student@workstation ~]$ lab start users-access
Instructions
Define a host-based access rule (HBAC) rule to allow access to a set of users to the vsftpd, SSH, and FTP services.
On workstation, navigate to the IdM console at https://idm.lab.example.com.
Log in as the admin user with RedHat123^ as the password.
Create and customize the allow_remote_access rule.
Disable the allow_all rule after you create the allow_remote_access rule.
Navigate to → → and then click .
When prompted, set allow_remote_access as the name of the rule and click .
In the section, verify that is selected, and then click .
Select the idmuser01, idmuser04, and idmuser05 users, and then click to move the selected users to the column.
Click .
In the section, verify that is selected, and then click .
Select the client.lab.example.com machine and click to move the host to the column.
Click .
In the section, verify that is selected, and then click . Select the , , and services from the column and click to move the services to the column. Click .
Return to the HBAC rules list by clicking at the top of the window.
Verify that the allow_all and allow_remote_access rules are listed.
Select the allow_all rule, click , and then click .
Add the httpd HBAC service.
Navigate to → → and then click .
Enter httpd in the and fields, and then click .
Create and customize the Web Access service group.
Navigate to → → and then click .
Enter Web Access in the and the fields, and then click .
Click to list all available services. Select the service, click to move the service to the column, and then click .
Create an HBAC rule that allows a set of specified users to access the client machine via the Web Access service group.
Navigate to → → and then click .
Enter allow_web as the rule name and then click .
In the section, verify that is selected, and then click .
Select the idmuser01 user, click to move the user to the column, and then click .
In the section, verify that is selected.
In the section, verify that is selected. Click in the . Select the service group, click to add the service group to the list of prospective service groups, and then click .
Click .
Test the HBAC rules.
Navigate to → → . Select the parameters of the test according to the following table.
| List | Select |
|---|---|
idmuser03
| |
client.lab.example.com
| |
sshd
| |
allow_remote_access
|
On the tab, click to run the simulation.
On the right side of the tab, the console shows an ACCESS DENIED message because the idmuser03 user is not a member of the HBAC rule.
Open a terminal and log in to the client machine as the idmuser03 user.
The connection fails because the user is not a member of the rule:
[student@workstation ~]$ssh idmuser03@clientConnection closed by 172.25.250.11 port 22
Try to log in to the client machine as the idmuser04 user.
The connection is successful because the user is a member of the rule:
[student@workstation ~]$ ssh idmuser04@client
...output omitted...
[idmuser04@client /]$Return to the workstation machine as the student user:
[idmuser04@client /]$ exit
logout
[student@workstation ~]$Test the HBAC rule that limits access to the httpd service.
In the IdM console, navigate to → → . Select the test parameters according to the following table:
| List | Select |
|---|---|
idmuser01
| |
client.lab.example.com
| |
httpd
| |
allow_web
|
On the tab, click to run the simulation.
On the right side of the tab, the console shows an ACCESS GRANTED message because the idmuser01 user is a member of the HBAC rule.
Navigate to → → , select the rule, and click . Select the rule and click .
Add the group administrator role to a group.
Navigate to → → and click the user. Scroll down to the fields. Click the list and assign as the manager. Scroll up to the top of the page and click .
In a terminal, log in to the idm machine as the student user and become the root user.
Authenticate to IdM as the admin user, using RedHat123^ as the password:
[student@workstation ~]$ssh idm[student@idm ~]$sudo -i[sudo] password for student:student[root@idm ~]#kinit adminPassword for admin@LAB.EXAMPLE.COM:RedHat123^
Create the groupadmin role:
[root@idm ~]# ipa role-add --desc="Group Administrator" \
groupadmin
-----------------------
Added role "groupadmin"
-----------------------
Role name: groupadmin
Description: Group AdministratorAdd the Group Administrators privilege to the groupadmin role:
[root@idm ~]# ipa role-add-privilege --privileges="Group Administrators" \
groupadmin
Role name: groupadmin
Description: Group Administrator
Privileges: Group Administrators
----------------------------
Number of privileges added 1
----------------------------Add the idmgroup02 group to the groupadmin role and exit the idm machine:
[root@idm ~]#ipa role-add-member --groups=idmgroup02 groupadminRole name: groupadmin Description: Group Administrator Member groups: idmgroup02 Privileges: Group Administrators ------------------------- Number of members added 1 ------------------------- [root@idm ~]#exitlogout [student@idm ~]$exitlogout Connection to idm closed.
In the IdM console, navigate to → → . Click , and then click .
Verify that idmgroup02 is assigned to the groupadmin role.
Add a Sudo rule to allow the idmuser01 user to restart the client machine.
Navigate to → → and then click to create a command for the rule.
Enter /sbin/reboot as the Sudo Command and then click .
Navigate to → → and then click to create a rule.
Enter reboot_client as the rule name and then click .
Create the rule according to the following information. Leave all other fields untouched.
| Section | Value |
|---|---|
idmuser01
| |
client.lab.example.com
| |
/sbin/reboot
|
On the client machine as the idmuser01 user, verify the Sudo rules.
Verify the output of the sudo -l command.
When prompted, use RedHat123^ as the password:
The Sudo rule might take some time to propagate to the client machine.
You can clear the SSSD cache by using the sss_cache -E command as the root user to fetch the most recent rules.
[student@workstation ~]$ssh idmuser01@client[idmuser01@client /]$sudo -l[sudo] password for idmuser01:RedHat123^...output omitted... User idmuser01 may run the following commands on client: (root) /sbin/reboot
Reboot the client machine using the sudo reboot command.
Use RedHat123^ as the password:
[idmuser01@client /]$ sudo reboot
Connection to client closed by remote host.
Connection to client closed.
[student@workstation ~]$Log in to the client machine as the idmuser01 user and verify that it was rebooted:
[student@workstation ~]$ssh idmuser01@client[idmuser01@client /]$uptime23:03:09 up 0 min, 1 user, load average: 0.13, 0.04, 0.01
Return to the workstation machine as the student user:
[idmuser01@client /]$ logout
logout
[student@workstation ~]$