DEV Community

Discussion on: WSL Tips: Starting Linux Background Services on Windows Login

Collapse
 
peteravram profile image
Peter Avram

It turns out you can enable password-less sudo for specific commands without enabling the security faults of allowing your user to sudo just anything without any safety check. Open visudo to edit your sudo config:

I would not do what is suggested here.

What you have done is allowed passwordless execution of a user-editable shell script haven't you?

If I wanted to execute arbitrary code under sudo I would simply edit that shell script and then use the permission to execute that shell script as a sudo user.

You need to make sure that whatever script you are allowing anyone to call without providing the SUDO password (as the sudo user) is uneditable.

Otherwise there is NO advantage to trying to avoid allowing passwordless SUDO.

I'm not a nix guru, so I don't have a working solution for others to read here, but the specific advice given here isn't great, I'd suggest looking for a different script that is owned by the sudoers that cannot be edited by a non-sudo'er to allow passwordless sudo'ers to execute to achieve the same functionality.