Jump to content

Recommended Posts

Posted

Hy

i use octoprint on my orange pi.

 

Now i need to resart and shutdown the system by octoprint.

So i try shutdown -h 0 or systemctl poweroff

 

nothing will work, cause i need to authenti.  the user by password.

 

so i tried to add the user to the sudoers... not work

this is my line. i added the code at the end of the file

myuser ALL=(ALL) NOPASSWD: /sbin/shutdown

 

Posted

Not sure about doing it for just one command, but you can make it so you don't need to authenticate when using sudo.

 

sudo mkdir -p /etc/sudoers.d/
sudo tee /etc/sudoers.d/010_$USER-nopasswd <<EOF
$USER ALL=(ALL) NOPASSWD: ALL
EOF

 

Posted

This works for me. Edit it to fit the commands you want to be able to run.

sudo tee /etc/sudoers.d/010_$USER-nopasswd <<EOF
${USER} ${HOSTNAME} = (root) NOPASSWD: /sbin/shutdown
${USER} ${HOSTNAME} = (root) NOPASSWD: /sbin/poweroff
${USER} ${HOSTNAME} = (root) NOPASSWD: /sbin/reboot
EOF

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines