0

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?

1

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
1
  • 2
    Make sure that none of the directories in the path to the script, nor path/to/script itself, can be modified by your developer. Otherwise they would be able to substitute or edit the script, which will be running with root privileges – roaima Nov 21 '20 at 11:21
0

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.

Caution: use 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.