How to allow users to run a script with root privileges?

Given the danger of SUID shell scripting , is there a safer way to provide root-free scripting access (bash, PHP) on Linux?

(Ubuntu 8.10)

+7
security linux scripting passwords ubuntu
source share
9 answers

You may consider sudo .

Although this is not a "password without password", it does not require a root password from the user. It can also provide an audit trail using a script.

edit: according to Chris’s comment, it’s possible not to require a password for certain commands, see here for more details, It can also be configured not to excessively exceed the password, i.e. A single password entry can be useful for several commands during the period of use.

By the way, sudo is built into Ubuntu and integrates perfectly with Gnome. When ubuntu offers you a password for privileged operations, it is sudo under the hood.

+13
source share

alt text

+15
source share

Be sure to check the β€œ SHELL ESCAPES PREVENTION ” section of the sudoers manual page if you are following the sudo route.

+6
source share

I would recommend sudo . Be sure to tighten your sudoers file accordingly; and yes, you can allow the execution of some commands without asking for a password.

+5
source share

Setting up sudo to allow ordinary users to run shell scripts with elevated privileges is no better security than creating a root script root. All traps still exist. Instead, you should write a proper program that will conduct extensive security checks. Some points to consider:

Do not write in C, you shoot in both legs. Check all inputs. Grant privileges as soon as possible. Keep it short.
+4
source share

Since sudo has already been mentioned, you might want to consider different sandboxes, depending on your needs β€” for example, jail or similar.

+2
source share

To increase security, consider whether it is possible to perform the operation as a special user or group that has exactly the access rights necessary for this. Then you can do the script setuid / setgid for this user or group.

+1
source share

For a really tough decision, consider a MAC (Mandatory Access Control) system such as SELinux, AppArmor, TrustedBSD, etc.

+1
source share

If the use case is a machine running under VirtualBox, and safety is not really a problem, you just want the light barrier to not allow yourself to shoot in the leg, then what? (Then the security arguments don't really make sense, because it doesn't matter if the computer is compromised by an outsider who still can't see it because VirtualBox isolates it through NAT.)

0
source share

All Articles