Passwords in Linux scripts?

AmigaOne X5000 platform specific issues related to Linux only.
Post Reply
Roland
Posts: 825
Joined: Tue May 02, 2017 7:23 am

Passwords in Linux scripts?

Post by Roland »

I would need to run "sudo su" in a script (.sh), but how can I include the password it needs? (No need to worry about security, the script will not launch nuclear weapons... ; )
- Roland -
User avatar
xeno74
Posts: 9348
Joined: Fri Mar 23, 2012 7:58 am

Re: Passwords in Linux scripts?

Post by xeno74 »

What do you think about this?

sudo visudo

Code: Select all

username ALL=(ALL) NOPASSWD: ALL
Where username is the user who executes the script.
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.
Roland
Posts: 825
Joined: Tue May 02, 2017 7:23 am

Re: Passwords in Linux scripts?

Post by Roland »

xeno74 wrote:What do you think about this?

sudo visudo

Code: Select all

username ALL=(ALL) NOPASSWD: ALL
Where username is the user who executes the script.
Thanks for the tip! Unfortunately, it works only partially... If I open a Term window, I can now use 'sudo su' without password. But the script where I have 'sudo su' on the first line still doesn't work, except from 'root'. Is there a way to get some output from a script, error messages etc.?
- Roland -
User avatar
xeno74
Posts: 9348
Joined: Fri Mar 23, 2012 7:58 am

Re: Passwords in Linux scripts?

Post by xeno74 »

Why sudo su? You can execute your script with sudo.
http://www.amigalinux.org
http://www.supertuxkart-amiga.de

Running Linux on AmigaONEs can require some tinkering.
Roland
Posts: 825
Joined: Tue May 02, 2017 7:23 am

Re: Passwords in Linux scripts?

Post by Roland »

xeno74 wrote:Why sudo su? You can execute your script with sudo.
When I first tested the individual commands for the script in a terminal, one of them needed that I use "sudo su". Plain "sudo" was not able to run it. So I thought I have to have 'sudo su' as the first command in the script!

But only after reading your comment above I understood that you speak about a different, "two-layer" approach, where the primary script is run via an auxiliary script with "sudo script_name". That indeed works and solved the problem - thank you !-)
- Roland -
Post Reply