I'm pretty new to the deployment world but this is what's going on. I have a new Ubuntu (Ubuntu 16.04.4 LTS) droplet from DigitalOcean. I installed and configured nginx and everything is working smooth. I turn it on and off with: service nginx start/service nginx stop but I need to be able to do this with a different user called pepito.

When I try to run service nginx start with pepito I get:

~# service nginx restart
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'nginx.service'.
Authenticating as: pepito

But I'm going to be running this from Capistrano so I don't want to be asked to enter the password, so I added this to visudo like this:

pepito ALL=(ALL) NOPASSWD: /usr/sbin/service nginx*

Tried again and same problem. Keep googling and reading and find out that ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === is a message from Polkit so I read a little about it and created the following file in: /etc/polkit-1/localauthority/50-local.d/nginx.pkla


Of course it doesn't work when I try to start and stop nginx from pepito. I don't know what else to try!


With the visudo command you edited the file /etc/sudoers, which only applies if you prefix your commands with sudo, in your case sudo service nginx start.

  • Thanks dude! It was driving me crazy. I'll just avoid using Polkit that I can't understand! – Andres Mar 8 '18 at 16:20
  • 1
    Sudo is the general mechanism in Linux/Unix to provide fine-grained access to superuser rights. – Nils Magnus Mar 10 '18 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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