Hi, I try to make one bash script to be run as root as a user without the password being asked for. As a test to see how this works, I edited sudoers with visudo and added this line at the end of the file: karl ALL= NOPASSWD: /bin/su After a restart I expected user karl to be able to run su without password. It didn't work, where's my mistake? thanks, Karl
On 30.03.2021 22:09, Karl Sinn wrote:
Hi,
I try to make one bash script to be run as root as a user without the password being asked for.
As a test to see how this works, I edited sudoers with visudo and added this line at the end of the file:
karl ALL= NOPASSWD: /bin/su
After a restart I expected user karl to be able to run su without password.
It didn't work, where's my mistake?
What is output of which su ??
On 30/03/2021 21.09, Karl Sinn wrote:
Hi,
I try to make one bash script to be run as root as a user without the password being asked for.
As a test to see how this works, I edited sudoers with visudo and added this line at the end of the file:
karl ALL= NOPASSWD: /bin/su
Why not karl ALL= NOPASSWD: /usr/local/bin/whateverscript ?
After a restart I expected user karl to be able to run su without password.
Restart is not needed. -- Cheers / Saludos, Carlos E. R. (from 15.2 x86_64 at Telcontar)
Hi, I managed to solve the problem. thanks for all the answers!! Karl Am 30.03.21 um 21:09 schrieb Karl Sinn:
Hi,
I try to make one bash script to be run as root as a user without the password being asked for.
As a test to see how this works, I edited sudoers with visudo and added this line at the end of the file:
karl ALL= NOPASSWD: /bin/su
After a restart I expected user karl to be able to run su without password.
It didn't work, where's my mistake?
thanks, Karl
On 3/30/21 10:58 PM, Karl Sinn wrote:
I managed to solve the problem.
Please share. Someone searching the web for this particular issue in future and hitting this thread will be happy to see how the problem was solved. Thanks & have a nice day, Berny
Am 31.03.21 um 00:02 schrieb Bernhard Voelker:
On 3/30/21 10:58 PM, Karl Sinn wrote:
I managed to solve the problem.
Please share. Someone searching the web for this particular issue in future and hitting this thread will be happy to see how the problem was solved.
1) make sure the path you use really points on the script/program you wanna use 2) make sure to understand which exact process throws the error message 3) and then rtfm :) my main problem was connected to wrongly calling xfce4-terminal, I didn't know/understand how the -x option works. Not really connected to the topic of the thread, therefor I didn't mention it. thanks Karl
Thanks & have a nice day, Berny
On 3/31/21 10:56 AM, Karl Sinn wrote:
1) make sure the path you use really points on the script/program you wanna use 2) make sure to understand which exact process throws the error message 3) and then rtfm :)
my main problem was connected to wrongly calling xfce4-terminal, I didn't know/understand how the -x option works.
Thanks for letting us know. Have a nice day, Berny
On 3/30/21 2:09 PM, Karl Sinn wrote:
visudo and added this line at the end of the file:
karl ALL= NOPASSWD: /bin/su
sudo has nothing to do with su. For karl to su without a password: (1) add karl a member of the wheel group (you may have to use yast to create the wheel group a a system group. I don't recall if openSUSE has it by default -- it does in my 15.2 installs) (2) as root edit /etc/pam.d/su now uncomment the lines where it tells you to: # Uncomment the following line to implicitly trust users in the "wheel" group. auth sufficient pam_wheel.so trust use_uid # Uncomment the following line to require a user to be in the "wheel" group. auth required pam_wheel.so use_uid No restart or reboot needed, just 'su' as karl and you are root. I prefer to give root a distinguishable PS1 prompt to make it visually apparent I've su'ed to root. The following is a useful root prompt: export PS1="\[\e[1;34m\][\[\e[38;5;203m\]\A \[\e[1;34m\]\h\[\e[38;5;197m\]:\w\[\e[1;34m\]] # \[\e[0m\]" which enderes as: [03:59 valkyrie:/home/david] # (the outputer [..] are dark blue, the time is maroon, the host is blue and path is a darker-red with the root # shown in blue (with one spade behind and in frong of it. it provide a 24-hour clock and the host and directory names are in the form to simply select and use in ssh or other network paths. The hostname:/path/to/where is the format used by ssh, sftp, etc The user-prompt I use is similar, in format: export PS1="\[\e[38;5;244m\]\D{%R}\[\e[38;5;32m\] \h:\w> \[\e[0m\]" Give both a try and see if one will fit your needs. -- David C. Rankin, J.D.,P.E.
participants (5)
-
Andrei Borzenkov
-
Bernhard Voelker
-
Carlos E. R.
-
David C. Rankin
-
Karl Sinn