I need that a new user could execute sudo without any request of password, because this user has in crontab a .sh that uses sudo for some commands.
I created a new user on my ubuntu server 16.04 x64
adduser my-user sudo
gpasswd -a my-user sudo
Then using visuo i added this line, based on this question
my-user ALL=(ALL) NOPASSWD : ALL
Then rebooted
After reboot I logged in using my-user and tried to do sudo clear, but it ask me the sudo password.
NOTE: I've added the crontab using crontab -e my-user so I suppose my script is executed as my-user. In fact, the crontabbed script crashes telling me in the log about a sudo request of password. I really need to execute the script in this way to be able to create file with my-suer as owner.
Please tell me if some steps/lines were not needed and how to make able my-user to execute sudo without password request.
Thanks
PS: I seen this question, but I'm not able to make it working so I need a more precise explanation, because my situation is different: i'm running a crontab script and I need it do not ask for sudo password
crontab -e my-userso I suppose my script is executed asmy-user. In fact, the crontabbed script crashes telling me in the log about asudorequest of password – realtebo Jul 09 '16 at 09:03sudo crontab -e) instead of putting them in a user crontab with sudo inside. – steeldriver Jul 09 '16 at 13:11crontabwith a package not too particular about respecting initial file ownership andrwxmode. -- 1) to create a new user, keep it simple: firstsudo adduser my-userthensudo gpasswd -a my-user sudo. Start again from scratch by deleting yr user if necessary. -- 2) to include a new entry with aNOPASSWDtag insudoersor in a file in/etc/sudoers.d/, make the colon sticks to the tag. E.g.NOPASSWD:. I've not seen it before with interspersed space. – Cbhihe Jul 10 '16 at 09:04