1

My user is 'peaagent'. I have tried visudo -f /etc/sudoers.d/peaagent with the following:

peaagent ALL = (root) NOPASSWD: /bin/systemctl stop postgresql.service

When I try stop Postgresql as peaagent it prompts me for a password:

peaagent@myserver:~$ /bin/systemctl stop postgresql.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to stop 'postgresql.service'.
Authenticating as: root
Password:

Anyone know why this doesn't work? Tx.

David Tinker
  • 557
  • 1
  • 8
  • 16
  • What exactly happens, what error messages do you see, what relevant messages are there in your logs ? – user9517 Aug 19 '16 at 07:01
  • I don't get an error, it just prompts me for a password which I don't want. Nothing in /var/log/syslog. Is there another log file I should be looking at? – David Tinker Aug 19 '16 at 07:07

1 Answers1

3

Your problem is that you are not prefixing your command with sudo. As you are attempting to run a systemd command without sufficient privilege, systemd is asking for a password (via systemd-ask-password) to a suitably privileged account.

sudo  /bin/systemctl stop postgresql.service

should do what you want.

user9517
  • 114,104
  • 20
  • 206
  • 289