Hi.
Suppose I want to start a process from a script with a sudo or su command like this:
su -root /path_to/command
or this, I don’t really care which:
sudo /path_to/command
Is there an option to put the root password in there somewhere so the command will run from a script started by a normal user. I understand the security implications.
Modify /etc/sudoers (see man page for exactly how, or one of a million
posts online) and add the ‘NOPASSWD’ option for when you run your script
so that you just are not prompted. Storing passwords in files is just
better to be avoided.
Good luck.
swerdna wrote:
> Hi.
> Suppose I want to start a process from a script with a sudo or su
> command like this:
> su -root /path_to/command
> or this, I don’t really care which:
> sudo /path_to/command
>
> Is there an option to put the root password in there somewhere so the
> command will run from a script started by a normal user. I understand
> the security implications.
>
> Thanks
> Swerdna
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
I would solve this with the setuid-bit. Let’s say your script is named /root/bin/foo.sh. First you make root the owner of the script:
chown root:users /root/bin/foo.sh
Then you change the rights like this:
chmod 4750 /root/bin/foo.sh
Now the script is executable for users which are in the group users but runs with root rights. Be careful with this. I would also add a special group for that issue where only trusted users are in.
erikro wrote:
> Hi,
>
> swerdna;1922113 Wrote:
>> Hi.
>> Suppose I want to start a process from a script with a sudo or su
>> command like this:
>> su -root /path_to/command
>> or this, I don’t really care which:
>> sudo /path_to/command
>>
>> Is there an option to put the root password in there somewhere so the
>> command will run from a script started by a normal user. I understand
>> the security implications.
>>
>
> I would solve this with the setuid-bit. Let’s say your script is named
> /root/bin/foo.sh. First you make root the owner of the script:
>
>
> Code:
> --------------------
>
> chown root:users /root/bin/foo.sh
>
> --------------------
>
>
> Then you change the rights like this:
>
>
> Code:
> --------------------
>
> chmod 4750 /root/bin/foo.sh
>
> --------------------
>
>
> Now the script is executable for users which are in the group users but
> runs with root rights. Be careful with this. I would also add a special
> group for that issue where only trusted users are in.
>
> hth
>
> Greetings
>
> Erik
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org