- Lab
- A Cloud Guru
Enabling su/sudo Access with Wheel Group
System Administrators rarely log into a system as `root`, due to a number of security risks. Some distributions even disable the `root` account to begin with. Restricting the ability to use `root` privileges to selected users is an important part of maintaining a secure system. In this activity, you will learn how to secure the `su` and `sudo` commands by restricting their use to members of the `wheel` group.
Path Info
Table of Contents
-
Challenge
Confirm Your User Is in the wheel Group and Set the /usr/bin/sudo and /usr/bin/su Files so They Can Be Executed by the root User and wheel Group
Use the
id
andgroups
commands to confirm yourwheel
group membership:id groups
Use
sudo
to become the root user:sudo -i
Run
chgrp
to set thewheel
group as the owner of/usr/bin/sudo
and/usr/bin/su
:chgrp wheel /usr/bin/sudo /usr/bin/su
Use
chmod
to set the most secure permissions, and allow theroot
user andwheel
group to executesudo
andsu
:chmod 4110 /usr/bin/sudo /usr/bin/su
Run
ls -l
on either of those to confirm. -
Challenge
Use visudo to Confirm, Create, or Uncomment Entry Allowing wheel Group to Use sudo
To modify or verify
/etc/sudoers
allows the wheel group to use sudo, use thevisudo
command:visudo
We need a line that looks like this:
%wheel ALL=(ALL) ALL
It may already be there, or it may be there and commented out. It's usually down in the vicinity of the
root
line. Save changes to the file and exit. Usegrep
to verify the line is there.grep wheel /etc/sudoers
-
Challenge
Uncomment or Create a Line in /etc/pam.d/su to Require wheel Group Membership for Using the su Command
Using the editor of your choice, uncomment or create an additional "auth" test below the line ending with
pam_rootok.so
. The line should look like this:auth required pam_wheel.so use_uid
-
Challenge
Create a sysadmin User, Make Them a Member of the wheel Group, Set Their Password, and Verify sysadmin Is Able to Use sudo and su
Create the
sysadmin
user and make them a member of thewheel
group:useradd -G wheel sysadmin
Running it this way would work too:
useradd sysadmin usermod -aG wheel sysadmin
Now we can set the
sysadmin
user password:passwd sysadmin
Verify
sysadmin
can executesu
andsudo
:su - sysadmin sudo tail -n1 /etc/shadow su -l cloud_user exit exit
-
Challenge
Create a User, sysuser, Who Is Not a Member of the wheel Group, Set Their Password, and Verify That They Are Not Able to Use sudo and su
Create the
sysuser
user and do not make them a member of thewheel
group:useradd sysuser
Set the
sysuser
user password.passwd sysuser
Verify
sysuser
cannot executesu
andsudo
:su --login sysuser sudo tail -n1 /etc/shadow su -l cloud_user exit exit
The
sudo
and followingsu
commands should have both failed.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.