In this hands-on lab, we will be looking at how we can delegate privilege elevation and allow users to access sensitive areas of the system in a controlled manner.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Configure `sudo` to Create an `ADMINUSER` `User_Alias` Containing `testuser` and an `ADMINTASKS` `Cmnd_Alias` for the Required Commands. Verify `testuser` Can Complete the Commands.
Edit the
sudoers
file:sudo -i visudo
Edit the contents of the file so it contains these lines in the appropriate sections (Hint: Use
/
to find the areas, and there are three lines of content to be added.):User_Alias ADMINUSER = testuser Cmd_Alias ADMINTASKS = /usr/sbin/useradd, /bin/passwd, sudoedit /etc/hosts ADMINUSER ALL=ADMINTASKS
Comment out the following lines (
Defaults targetpw
may not exist):#Defaults targetpw #ALL ALL=(ALL)ALL
Save the file and verify
testuser
is able to create a user:su testuser #password is P@ssw0rd sudo useradd someuser
See if
someuser
appears in/etc/passwd
:grep some /etc/passwd
- Grant `admin_user` the Same Permissions as the `root` User
As the
cloud_user
, editsudoers
:visudo
Copy the
root
entry to the next line and substituteadmin_user
forroot
in the user position:root ALL=(ALL)ALL admin_user ALL=(ALL)All
Save and exit, and then become the
admin_user
:su admin_user
Run
visudo
to see if you are allowed:sudo visudo
Exit the file.