I have a bash file that the web developer would need to run once in a while, which contains commands to reset some file permissions. These commands have to be run under the root security context. I would like to allow the developer to execute this file and have it run as root. However I don't want to give the developer sudo access to the entire server, but rather only root context to run this bash file. What would be the best way to configure this on Redhat?
However I don't want to give the developer sudo access to the entire server, but rather only root context to run this bash file.
Why would you give access to the entire server when you can set up sudo to allow the user to run a single bash script?
cat /etc/sudoers.d/script4username username ALL=(ALL) NOPASSWD: /path/to/script
It turns out that
sudo is the right tool for what you want to do.
You can set up
sudo for fine grained access control: Both who and what. Read
man sudoers. Also ensure that the user has to write access to the script or its containing directory.
visudo to edit the sudoers file. It will check for errors, and error can get you locked out. Also leave a root terminal running, just in case.