17

I'd like to know how I can disable the authentication prompts when opening apps such as Synaptic, mounting disks and so.

I got my user as passwordless set in sudoers, but seems the change to systemd changed something and now I keep getting prompted. Is there any way to set it like sudo in /etc/sudoers so my user can open such apps unprompted?

I am aware of the security risk, but this computer is not connected to the internet and no one else has access to it, I am aware of the safety risk, but I want to do this anyway, for convenience.

1 Answers1

31

As I understand it, these prompts use Polkit, not sudo, for authorization. Therefore, setting NOPASSWD in sudoers won't make any difference to it. To make Polkit skip password prompts, create a .pkla file in /etc/polkit-1/localauthority/50-local.d/ (say /etc/polkit-1/localauthority/50-local.d/99-nopassword.pkla) containing:

[No password prompt]
Identity=unix-group:sudo
Action=*
ResultActive=yes

See the pklocalauthority manpage for more information.


For Ubuntu 23.10 and newer, which come with Polkit > 0.106, you need to use JavaScript rules instead. Create a .rules file in /etc/polkit-1/rules.d/ (say 99-nopassword.rules) containing:

polkit.addRule(function(action, subject) {
    if (subject.isInGroup("sudo")) {
        // or subject.user == "muru"
        return polkit.Result.YES;
    }
});

Check the Arch Wiki for more examples.

muru
  • 207,228