phpdebiansudohashcat

How to allow user www-data use sudo commands without password


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:

  1. check where is program catalogue whereis hashcat -> hashcat: /usr/bin/hashcat
  2. Add a new file to sudo visudo /etc/sudoers.d/www-data and add next line www-data ALL=(www-data:www-data)NOPASSWD: /user/bin/hashcat
  3. 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?


Solution

  • 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!