Limit Sudo to specific commands

Limit Sudo to specific commands

Limit Sudo to specific commands

In this scenario, we have SUDO already setup, howewever we want to be a bit more restrictive as to what can be run via sudo. Login, and su to root

Root shell prompt on the terminal2 server

the first thing we need to do is determine the full path of the binary we want to sudo user to have access to. The best way to do this is with the “whereis” command. In this case, we are lookin up yum

sudoers line: %sudo ALL=(ALL) NOPASSWD: /usr/bin/yum

as we can see yum is stored in /usr/bin/yum

now edit the sudo config

visudo to edit the sudoers file

in this case we are graning the “sudo” LDAP group with the capability of not having to enter a password, and ability to update via YUM using /usr/bin/yum binary.

sudoers %sudo group allowed only /usr/bin/yum without a password

That’s it!

Hosted Linux Servers at www.zwiegnet.com/go

Related guides: 389 Sudo LDAP Integration CentOS 6 | Configure SSH Key Authentication Only

Leave a Reply

Your email address will not be published. Required fields are marked *