I'm using Ubuntu Mate for my raspy. I'm using my raspy to run a program 24/7, which requires to be started with sudo.
Because I don't want to do this manually, I added a script to "startup applications"... the problem is that "startup applications" get executed as raspy
(my default user).
So, I decided to fix this with visudo
.
I added following entry:
raspy ALL= (root) NOPASSWD: /usr/bin/myscript.sh
and rebooted.
Nothing changed- sudo sh /usr/bin/myscript.sh
still requires a password.
After that I tried a bit around [modifying this line, verifying its syntax always by visudo -c
...]..
I got this work:
raspy ALL = (raspy) NOPASSWD: /usr/bin/myscript.sh
which allows me to start the script as raspy
without having to enter password.
The file owner is root, file owning group is root, permissions are 700 .
What have I to insert in Visudo, that I can execute my script as root ( with this sudo sh /usr/bin/myscript.sh
) without having to enter a password?
sudo sh /usr/bin/myscript.sh
runssh
as root, which your sudoers line did not allow. Try running it without thesh
@reboot
directive. Put it in the system crontab and it will run as root (which appears to be what you want)