Score:0

NOPASSWD for single python script

in flag

To run a single script I made: /etc/sudoers.d/edison-user contain edison ALL=(ALL) NOPASSWD:ALL and it works fine. But when I change it to edison ALL=(ALL) NOPASSWD:/home/edison/script.py it does not. WHY? I need YOU to help me

cn flag
What is the problem exactly? Does your visudo complain about the syntax or does the sudo complain when you try to run your script?
cn flag
And, btw, this configuration is a security hole. Apparently, you're trying to allow edison user to run a script /home/edison/script.py as root. This edison user probably can put whatever he wants in that script.py and do anything. Basically, you're giving him full root rights and not just the ability to run a single script.
in flag
Visudo is all right. edison is me. I am giving permission for myself. I want to avoid typing my password only to run script.py.
cn flag
then it looks fine to me. What do you get if you try to run the script with sudo ?
in flag
Sometimes I use to try new things and go deeper in my knowledge of Linux. edison ALL=(ALL) NOPASSWD:/home/edison/script.py used to work on Ubuntu 21.04, but it gave me some problems and I moved, back, to 20.04 LTS. Config NOPASSWD for a single python script is not working anymore. I thought someone could have the answer.
cn flag
I'd like to help, but I don't see your issue. What happens when you run: sudo /home/edison/script.py ?
cn flag
Also, I would recommend to check that a line "@includedir /etc/sudoers.d" is present in /etc/sudoers. If it isn't, it means your /etc/sudoers.d/edison-user is not included in the main config and so has no effect.
in flag
bottom line, I want just a certain script to run without entering the password. The other programs should continue to demand to type the password as once happened.
in flag
#includedir /etc/sudoers.d is present. as far as I understood the # is not a comment. it is a directive.
Score:0
US flag
user1657489

You need to allow python to run it, so it would be something like:

edison ALL=(ALL) NOPASSWD: /usr/local/bin/python /home/edison/script.py

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.