I want to allow run specify command on my website, through PHP exec() function, so i found the way, to add www-data in sudoers.d files to allow run specify commands without asking password.
I tried next things:
- check where is program catalogue
whereis hashcat -> hashcat: /usr/bin/hashcat
- Add a new file to
sudo visudo /etc/sudoers.d/www-data
and add next linewww-data ALL=(www-data:www-data)NOPASSWD: /user/bin/hashcat
- Try to run it through www-data:
sudo -u www-data sudo hashcat
And then i get this:[sudo] password for www-data:
, that means it doesn’t seems to work
What can i do wrong, and what i should do then? And is my decision to do so correct? Is there a better and safer solution?
Advertisement
Answer
That problem is solved, by removing the (www-data:www-data)
so my “www-data: file in sudoers.d looks like: www-data ALL=NOPASSWD: /usr/bin/hashcat
Thanks all for answering and give me a hint to solve this! Especially thanks to @cyberbrain for my carelessness!