I have added a user like this:
$ adduser --system --home /no/home --no-create-home --group --disabled-password --disabled-login testuser
Added a user to a group:
$ adduser testuser testgroup
added lines to sudoers (visudo):
testuser ALL=(ALL) NOPASSWD: ALL
%testgroup ALL=(ALL:ALL) NOPASSWD: ALL
When I try to run the bash script with the following content:
#!/bin/sh
sudo -u testuser /usr/bin/php /usr/local/bin/script.php
But when I run this script, I get the error in the log:
sudo: no tty present and no askpass program specified
Edit: requiretty
is not in the sudoers file.
sudo
permissions about the user/group you are changing from not the user you are changing to? So aren't those lines letting thetestuser
user and thetestgroup
group run any command (as anyone) without a password? Don't you need to give permission to the user running the script to run commands as thetestuser
for what you want? Assuming that's what you meant to allow? – Etan Reisnersudo
as the testuser? What specifically did you run/try? What user is running the original script? – Etan Reisner