LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to tell shell script a password? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-tell-shell-script-a-password-432098/)

Etoile 04-05-2006 05:32 PM

How to tell shell script a password?
 
I'm running Ubuntu (Breezy) and I need to execute a 'sudo' command at startup. I don't think it will work through the "startup programs" window because sudo requires a password. So I want to write a shell script that I can just execute manually at startup. But how do I tell it what my password is so it can answer the Password prompt? Thanks!

Brian1 04-05-2006 05:47 PM

If all you need to do is one command I would edit /etc/sudeors file. You have to use ' visudo ' command to edit the file. In it I assume there is a section like this.
# Uncomment to allow people in group wheel to run all commands
%wheel ALL=(ALL) ALL

You can it to this so as not to need to use a passwd ever again. ( not the best idea )
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

Or just allow a single or a few commands to execute without roots password.
username ALL=NOPASSWD: /sbin/ifdown, /sbin/mount

Brian1

Etoile 04-05-2006 06:18 PM

I used your last suggestion and it did the trick for me. Many thanks!

Brian1 04-05-2006 06:41 PM

Yes the last one would be more secure. This way it limits the cammands you can do this way. The second one would work as long as you never add other users to the wheel group. Kind of gives you full root anytime with only the need to add sudo before the command to execute.

Brian1

mikshaw 04-05-2006 07:39 PM

If it's something that can be run before a user logs on, you can add it to your local boot script (/etc/boot.local or something similar). This script is run as root, so sudo is not necessary.

If it's a command that needs to be run in a graphical environment, then it won't work this way.

Etoile 04-05-2006 09:16 PM

Cool, thanks! Hopefully I can figure out BUM for that, or something. :)
edit - turns out to be "or something" :)


All times are GMT -5. The time now is 03:38 AM.