When I run a command like this on my raspberry pi I get the following output:
$ service sshd restart
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart »sshd.service«.
Authenticating as: ,,, (pi)
Password:
Doing the same on my Ubuntu Focal server I am getting a completely different result:
$ service sshd restart
Failed to restart sshd.service: Interactive authentication required.
See system logs and 'systemctl status sshd.service' for details.
I have tried to compare the polkit configuration to see why the raspberry is giving me a chance to authenticate while my server does not, forcing me to add the sudo and then run the command again as root.
On both systems the user I am using is in the sudo group, the linux server has
[Configuration]
AdminIdentities=unix-group:sudo;unix-group:admin
in a file in it's localauthority.conf.d, similar for the raspberry. I am not sure what is causing the behaviour on the raspberry, but on Ubuntu something causes it to fail immediately instead of asking me for authentication. Apparently someone at https://askubuntu.com/questions/1114351/why-system-keep-ask-to-enter-password-for-the-first-member-of-sudo-group-instead has the same result that I am having and there the issue was pinned down to the file /usr/share/polkit-1/actions/org.freedesktop.systemd1.policy
, so I have compared the file on both systems, and it's the same