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.
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.should do what you want.