RHCSA (026B): Season 2 - Scenario 1 of 25: Multi-Role Staging Environment Provisioning
RHCSA Lab 26B: Multi-Role Staging
Executive Summary
This RHCSA practice scenario details the complete provisioning of a secure, multi-role staging environment for a new application. The exercise is a comprehensive test of core system administration skills, starting with the creation of specific user and group accounts with designated IDs.
A key focus is on privilege management, demonstrating how to safely delegate limited administrative rights to a junior administrator using a dedicated sudoers file, while granting full sudo access to a lead administrator. The scenario reinforces security best practices by requiring a transition from the root account to a named administrative user for the bulk of the configuration.
Finally, the article covers the creation of a complex directory structure with advanced permissions. This includes the practical application of special permissions like the SGID bit to ensure correct group ownership in a collaborative developer directory and the sticky bit to protect files in a shared data directory. The solution provides a complete, step-by-step command guide followed by a thorough verification process to confirm that all configurations are correct and functional.
Keywords: RHCSA, Linux, System Administration, Privilege Management, User Management, Group Management, sudo, sudoers, File Permissions, Special Permissions, SGID, Sticky Bit, Security Best Practices, Server Provisioning, Multi-role Environment, Red Hat
The Problem
Mission
Your organization is deploying a new staging environment for a critical application named "Helios". You have been tasked with provisioning the user accounts, groups, and directory structures according to strict security and operational requirements. All configurations must be precise.
RHCSA Objectives Covered:
- 1.1: Issue commands with correct syntax, including less common options.
- 1.5: Log in and switch between multiple user contexts to perform tasks and verify permissions.
- 1.7: Create and edit system configuration files (e.g.,
/etc/sudoers.d/). - 1.8: Create a complex, multi-level directory structure and manipulate files within it.
- 1.10: Implement a multi-tiered permission scheme using standard (rwx), group ownership, and special permissions (SGID, Sticky Bit).
- 9.1: Create user accounts with specific UIDs, non-standard shells, and supplementary group memberships.
- 9.3: Create local groups with specific GIDs.
- 9.4: Configure fine-grained superuser access without modifying the default
sudoersfile.
Your Task
You will begin as the root user. Your first actions are to create a dedicated administrative account for yourself and then a limited-privilege administrator. After that, you must exclusively use your new admin account (adm_lead) for all subsequent tasks.
Requirements
- Initial Root Tasks:
- Create a local group named
administratorswith a Group ID (GID) of2000. - Create your primary administrative user account named
adm_lead. This user must have a UID of2000, a primary group ofadministrators, be a member of thewheelgroup, and have the passwordRhcsa!2025. - Create a junior administrator user account named
adm_jrwith the passwordJuniorP@ss.
- Create a local group named
- Configure Delegated Privileges:
- As
root, create a new file at/etc/sudoers.d/junior_adminto grant the useradm_jrthe ability to run/bin/dnfand/bin/systemctlwith superuser privileges, and nothing else. - Log out of the
rootsession. You must now log in asadm_leadand usesudofor all subsequent tasks.
- As
- Provision Project Groups and Users:
- Create a local group named
developerswith a GID of3000. - Create a service account named
helios_svcwith a UID of3000, a shell of/sbin/nologin, and no home directory. - Create a developer user named
anitawith a primary group ofdevelopersand the passwordDevPass!23.
- Create a local group named
- Create Directory Structure and Permissions:
- Create the directory structures:
/srv/helios/app/srcand/srv/helios/data/shared. - For
/srv/helios/app/src, set ownership toroot:developers. Permissions must allow the owner full control, group members read/write/access, and automatically set group ownership of new files todevelopers(SGID). Others must have no access. - For
/srv/helios/data/shared, set ownership toroot:developers. Permissions must allow all users to read/write/access, but only allow users to delete files they own (Sticky Bit).
- Create the directory structures:
- Final Verification:
- Copy
/etc/redhat-releaseto/srv/helios/app/src/release_info.txt. - Switch to the
anitauser. - As
anita, verify you can create a new file in/srv/helios/app/src. - As
anita, confirm the new file's group isdevelopers. - As
anita, verify you can readrelease_info.txtand can also write to it after a permission change is applied byadm_lead.
- Copy
Note: All users, groups, files, and permissions must be correctly configured and persist after a system reboot.
The Solution
Step 1: Initial System Configuration (Run as root)
Manual GID assignment for environment consistency:
groupadd -g 2000 administrators
Create the lead admin utilizing -u for specific UID, -g for primary group, and -G wheel for sudo access:
useradd -u 2000 -g administrators -G wheel adm_lead
Efficiently set the password for the lab user:
echo 'Rhcsa!2025' | passwd --stdin adm_lead
Create the junior admin and set their password:
useradd adm_jrecho 'JuniorP@ss' | passwd --stdin adm_jr
Grant specific command access to satisfy Objective 9.4 without modifying the main sudoers file:
echo 'adm_jr ALL=(ALL) /bin/dnf, /bin/systemctl' > /etc/sudoers.d/junior_admin
Step 2: Project Provisioning (Run as adm_lead)
Switch to the lead account to begin delegated project tasks:
su - adm_lead
Create the developers group:
sudo groupadd -g 3000 developers
Create the service account. The -s /sbin/nologin flag prevents interactive login, and -M skips home directory creation:
sudo useradd -u 3000 -s /sbin/nologin -M helios_svc
Create the standard developer account and set the password:
sudo useradd -g developers anitaecho 'DevPass!23' | sudo passwd --stdin anita
Step 3: Directory Structure & Special Permissions
Build out the directory paths:
sudo mkdir -p /srv/helios/app/srcsudo mkdir -p /srv/helios/data/shared
Configure ownership and apply the SGID bit (2XXX) to ensure files created by 'anita' belong to the 'developers' group:
sudo chown root:developers /srv/helios/app/srcsudo chmod 2770 /srv/helios/app/src
Configure ownership and apply the Sticky Bit (1XXX) to protect files in the world-writable shared directory:
sudo chown root:developers /srv/helios/data/sharedsudo chmod 1777 /srv/helios/data/shared
Step 4: Verification Sequence
From the adm_lead shell, stage a test file:
sudo cp /etc/redhat-release /srv/helios/app/src/release_info.txt
Switch to the developer user:
sudo su - anita
Verify file creation and confirm the SGID bit worked (the group should appear as 'developers' in the output):
touch /srv/helios/app/src/test.pyls -l /srv/helios/app/src/test.py
Check read and write permissions on the staged file. The write command will fail because the group lacks write permission on this specific file:
cat /srv/helios/app/src/release_info.txtecho "test" >> /srv/helios/app/src/release_info.txt
Drop back to the lead admin shell to apply the fix:
exit
Update the permissions as the administrator:
sudo chmod g+w /srv/helios/app/src/release_info.txt
Switch back to the developer user and test again. It will now succeed:
sudo su - anitaecho "test" >> /srv/helios/app/src/release_info.txt
Step 5: Lab Finalization
Exit the active shells to return to the root prompt:
exitexit
Run the grading script to verify all exam objectives were met:
./grade_ep0026.sh
Finally, run the cleanup script to reset the environment for your next practice run:
./cleanup_after_ep_0026.sh
