14

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.

muru
  • 197,895
  • 55
  • 485
  • 740

1 Answers1

27

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.

muru
  • 197,895
  • 55
  • 485
  • 740
  • 1
    That's great, works as expected. Thanks a lot! – plasmating Apr 27 '15 at 00:02
  • For some reason created pkla file is not working on my system. I have polkit 0.105 and 18.04. How to debug what is wrong? – Suncatcher May 06 '18 at 09:07
  • @Suncatcher afaik nothing significant has changed for Polkit in 18.04 (we're still well behind upstream 0.114 or the 0.112 release that include JavaScript rule definition support). Please post a new question with the exact filename and contents. You can leave a comment here when that's done, so I can take a look. – muru May 06 '18 at 09:13
  • created, but on 18.04 I have old 0.105 polkit. – Suncatcher May 06 '18 at 09:37
  • Is disabling policykit password prompts this way a security risk? On a system with a single admin user, can graphical applications take arbitrary actions? – Travis G. Jul 25 '20 at 04:03
  • @TravisG. no more or no less than a password-less sudo, I'd say. – muru Jul 29 '20 at 14:58
  • @mru: there's a subtle difference with plain sudo though: with sudo you need to prepend it to command and thus you are reminded of the potentially dangerous effects, while Polkit seems to be "trusting" you know what you're doing. I didn't find a way to just a button with "are you sure?" or something to that effect; am I missing something? – user1714490 Sep 16 '20 at 11:19
  • As mentioned in a response to this same question. You can use Identity=unix-user:scott to only allow the user scott to do the action. – FlexMcMurphy Jan 20 '21 at 01:04
  • This does not seem to work on my freshly installed Ubuntu 22.4 Automatic login does not work and I get several prompts asking for my password when I log in. – Ente Fetz Jun 02 '22 at 13:53
  • @EnteFetz in that case, post a new question detailing the exact changes made, please – muru Jun 02 '22 at 15:24
  • 1
    No luck for me in 22.04 ubuntu. echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$USER this command will work for me – NIrav Modi Jul 27 '22 at 12:29