1

How can normal users (users without sudo permissions) shutdown the system remotely?

2
  • Is the user pi not per default in the sudoers list on raspian, thus sudo shutdown -h should work?
    – Ghanima
    Jan 22, 2016 at 20:53
  • @Ghanima yes, but this question is about non privileged users.
    – someonr
    Jan 22, 2016 at 23:03

2 Answers 2

3

You can use policykit (make sure policykit-1 is installed).

Create as root /etc/polkit-1/localauthority/50-local.d/all_all_users_to_shutdown_reboot.pkla with the following content:

[Allow all users to shutdown and reboot]
Identity=unix-user:*
Action=org.freedesktop.login1.power-off;org.freedesktop.login1.power-off-multiple-sessions;org.freedesktop.login1.reboot;org.freedesktop.login1.reboot-multiple-sessions
ResultAny=yes

The advantage of this method is, that you can disallow a user to shutdown, if others are logged in (omit the *power-off-multiple-session).

2

The other way to do it is to add a line to your /etc/sudoers file:

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

Make sure you use visudo as root to edit the file. They will need to be on the box (ssh) to be able to run the shutdown command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.