Passwords in Linux scripts?

AmigaOne X5000 platform specific issues related to Linux only.

Passwords in Linux scripts?

Postby Roland » Tue Jun 05, 2018 8:07 pm

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 -
Roland
 
Posts: 180
Joined: Tue May 02, 2017 8:23 am

Re: Passwords in Linux scripts?

Postby xeno74 » Wed Jun 06, 2018 8:19 am

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.
User avatar
xeno74
 
Posts: 3730
Joined: Fri Mar 23, 2012 8:58 am

Re: Passwords in Linux scripts?

Postby Roland » Wed Jun 06, 2018 2:19 pm

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 -
Roland
 
Posts: 180
Joined: Tue May 02, 2017 8:23 am

Re: Passwords in Linux scripts?

Postby xeno74 » Wed Jun 06, 2018 3:56 pm

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.
User avatar
xeno74
 
Posts: 3730
Joined: Fri Mar 23, 2012 8:58 am

Re: Passwords in Linux scripts?

Postby Roland » Wed Jun 06, 2018 9:56 pm

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 -
Roland
 
Posts: 180
Joined: Tue May 02, 2017 8:23 am


Return to Platform: AmigaOne X5000 - Linux Only

Who is online

Users browsing this forum: No registered users and 3 guests

cron