polkit (formerly Policy Kit) provides two important services.

From the project documentation:

an authorization API intended to be used by privileged programs (“MECHANISMS”) offering service to unprivileged programs (“SUBJECTS”) often through some form of inter-process communication mechanism.

...and...

allows users to obtain temporary authorization through authenticating either an administrative user or the owner of the session the client belongs to.

The first provides a safe way for user-level applications to ask for root-level actions. You might use this regularly without noticing in Desktop systems -- like suspending, or mounting newly-inserted hardware. Polkit is part of that mysterious glue that makes the desktop work.

The second is (most commonly) the GUI "admin privileges are required for this actions" dialog.


polkit is a necessary element in all Ubuntu Desktop (GUI) systems. Removing polkit will destroy your Ubuntu Desktop (GUI) system. It's generally not needed if you run headless (without GUI / Ubuntu Server), though folks do sometimes add software that needs polkit.

Answer from user535733 on askubuntu.com
🌐
Arch Linux Forums
bbs.archlinux.org › viewtopic.php
[SOLVED] Disable Polkit Services? / GNU/Linux Discussion / Arch Linux Forums
I'm really tempted to run `sudo rm /usr/share/polkit-1/actions/*` at this point because I think users should be denied shutdown access (and other things offered to standard users via polkit) if they don't use sudo. Just my opinion since I'm running a multi-user server with Arch. Only downside to running that command is that the next time I update, they will reappear... I guess I could empty them, but I would rather just disable polkit altogether if at all possible.
Discussions

polkit rule to enable/disable specific systemd service without password
Don't think it's possible. The only thing checking for org.freedesktop.systemd1.manage-unit-files in the codebase never passes any info about what it's managing; it's a simple yes/no check. This is in contrast to the main call source for org.freedesktop.systemd1.manage-units , which passes details about the unit and verb (start/stop/etc). I believe that giving wide access to manage-unit-files would allow someone to install and enable any unit they'd like (trivial escape to root from there), so sudo/doas is unfortunately your only real option. More on reddit.com
🌐 r/linuxquestions
4
9
October 19, 2022
The journey of purging polkit from your system on Gentoo
Hehe, know the feel, took me quite some time to get rid of dbus and replace udev(with mdev in my case). Good thing is, we can do it on Gentoo, even if it's some work. More on reddit.com
🌐 r/linux
51
10
August 17, 2015
Optional Feature: --disable-polkit
For embedded devices it would be useful if Polkit could be disabled. Since Polkit is dependent on mozjs. mozjs is about 25MB on the target device. Would this be a good or bad feature? Or does it ha... More on github.com
🌐 github.com
3
April 22, 2020
Can i disable "polkit.service"?
Can i disable “polkit.service”? If disabled, Is there a security problem? More on forum.manjaro.org
🌐 forum.manjaro.org
1
0
July 21, 2021
🌐
TheLinuxFAQ
thelinuxfaq.com › ubuntu › ubuntu-17-04-zesty-zapus › policykit-1
How to uninstall or remove policykit-1 software package ...
You can uninstall or removes an installed policykit-1 package itself from Ubuntu 17.04 (Zesty Zapus) through the terminal, · If you would like to remove policykit-1 and it's dependent packages which are no longer needed from Ubuntu,
🌐
Red Hat
access.redhat.com › solutions › 3468291
Is it safe to disable PolicyKit service? - Red Hat Customer Portal
What are the consequences of disabling polkitd? How to disable polkitd? Red Hat Enterprise Linux 7 · Red Hat Enterprise Linux 8 · Red Hat Enterprise Linux 9 · polkitd · A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.
🌐
Narkive
users.fedoraproject.narkive.com › iCrx9zci › how-do-i-disable-polkitd
How do I disable polkitd?
# perl -p -i -e 's@(^Exec=.*$)@# \1Exec=/bin/false\n at s' /usr/share/dbus-1/system-services/org.freedesktop.PolicyKit1.service 2. Make sure polkit will be disabled if a new version is installed: # yum -y install yum-plugin-post-transaction-actions # echo "polkit:install:perl -p -i -e 's@(^Exec=.*$)@# \1Exec=/bin/false\n at s' /usr/share/dbus-1/system-services/org.freedesktop.PolicyKit1.service" > /etc/yum/post-actions/polkit.action Gabriel - -- // Gabriel VLASIU // // OpenGPG-KeyID : 44952F15 // OpenGPG-Fingerprint: 4AC5 7C26 2FE9 02DA 4906 24B2 D32B 7ED7 4495 2F15 // OpenGPG-URL : http://www.vlasiu.net/public.key
🌐
Reddit
reddit.com › r/linuxquestions › polkit rule to enable/disable specific systemd service without password
r/linuxquestions on Reddit: polkit rule to enable/disable specific systemd service without password
October 19, 2022 -

I would like to create a polkit rule that allows a specific user to enable/disable a specific service (or alternatively just run it only on the next boot, but I think that would be more complicated) without being prompted for a password. I have a rule to allow the running/stopping of a service, but I can't seem to get the same for enabling/disabling right, so I am hoping someone here can help me.

I managed to get it to allow the user to enable/disable any service by checking action.id against org.freedesktop.systemd1.manage-unit-files, but action.lookup("unit") doesn't work in that case, so I can't check that way if it's the right service and allowing the user to manage all units without authentification seems excessive.

Also I am aware using sudo/doas would be an option, but if possible I would prefer the polkit solution.

Find elsewhere
🌐
Reddit
reddit.com › r/linux › the journey of purging polkit from your system on gentoo
r/linux on Reddit: The journey of purging polkit from your system on Gentoo
August 17, 2015 -

Okay, so, I decided to remove any trace of polkit from my system. Why? Because I never used it and that's what Gentoo is for. I'm not sure why I ever had it on my system, probably because the profile I choose at the start includes it. I honestly cannot recall ever doing something that requires access outside my home dir without elevating privileges so why not remove it? Well, turns out it's pretty hard to remove polkit to the point that repeated "This is BS" went through my mind attempting to do so. Did you know that it took me three recompiles of Wine to remove polkit? Yeah.

So, obviously, the simplest way to start is to remove the USE flag "policykit" from my global use flags and do a world update and see what happens. For those who don't know. USE flags are Gentoo's system of enabling parts of programs, one of the big reasons it's a source distro. Basically you instruct programs to no longer by default offer support for polkit, a world update then activates the necessary changes.

So about 8 packages get recompiled, about 8 outright get removed. That's nice isn't it, Gentoo's dependency system is flexible enough for packages to depend on other packages only if certain USE flags are turned on. So I thought "Well, this is easy", well, not really, turns out that one of the things that did not get removed was polkit itself, it's still there.

So, I check what stuff depends on polkit. One of them was pulseaudio, at this point I was ready to admit defeat. I could understand that pulseaudio depended on polkit and it used it to access the hardware or something. But no, this wasn't true, because Gentoo is awesome, turns out pulseuadio only depended on Polkit when Wine had a specific flag set. Yes, Portage's dependency system is flexible enough to let package X depend on package Y only if package Z has a specific flag set where Z does not depend on X. This is why resolving dependencies on Portage takes forever.

So, I removed that flag 'realtime' and recompiled wine and furthered my search. That recompilation of wine took quite some time actually and I regret that because I'm an idiot. Turns out there were two more flags with a similar relationship and I recompiled it two times fruther for those two while I could've done it in one time.

Next up was a pretty interesting and bizarre circular dependency. Basically, consolekit depends on polkit when consolekit has the USE flag "polkit" on. Okay, that seems reasonable. But when that flag is on, then polkit depends on consolekit or systemd. Does that make any sense? Well, it means a circular dependency is created the moment you install consolekit with polkit support. I later found out that Portage can easily delete two packages which circularly depend on each other by just asking to remove them within one command. The way I resolved it at the time was some "know what you are doing" tomfoolry by overriding the safety checks and unmegring the package even though polkit depended on it.

Next up was udisks which required polkit, this is just some dumb daemon that allows automatic mounting of external drives. A policy I am vehemently against. You should always elevate privileges I feel when you connect an external drive, So boom, that was gone, didn't even know I had it.

And finally. I have a system without polkit and consolekit that seems to work perfectly well.

So what if there weren't any USE flags, what if you ran a binary distro. Would you seriously then be required to have polkit installed just to run Kate or Wine without being able to compile that functionality out of it? Not sure but it seems to me that you would.

🌐
Ubuntu Forums
ubuntuforums.org › archive › index.php › t-1466794.html
[SOLVED] How to kill this service POLKITD? [Archive] - Ubuntu Forums
April 30, 2010 - Check http://ubuntuforums.org/showthread.php?t=1450707 You can also install rcconf and check whether is there another application related polkitd starting up.
Top answer
1 of 2
24

You can use the same technique Ubuntu's Live CD uses by tricking PolicyKit and suppressing ALL password prompts by substituting the action with a wildcard.

DISCLAIMER: The following will suppress ALL password prompts globally for everyone belonging to the admin group, with the exception of the login screen. It is EXTREMELY dangerous and should NEVER be implemented because chances are YOU WILL END UP BREAKING YOUR SYSTEM!!

Don't say you weren't warned!

NOTE: If you are running 12.04 or later, substitute "admin" with "sudo"!

Replace "username" with your actual user name:

usermod -aG admin username

Switch to root:

sudo -i

Create a new policy:

gedit /var/lib/polkit-1/localauthority/50-local.d/disable-passwords.pkla

Add the following:

[Do anything you want]
Identity=unix-group:admin
Action=*
ResultActive=yes

Save and exit. Then go try something that usually requires a password. :)

NOTE: It doesn't matter what you use as your .pkla file name. You can name it anything you want.

And last, this is the ONLY policy you'll need when it comes to suppressing password prompts because again, it does so globally.

2 of 2
11

You can create a .pkla, either an all in one or a couple based on action groups, doesn't really matter.

For reference look in /usr/share/polkit-1/actions, open interested ones in a text editor to get action id's.

As far as a .pkla or 2 I find the best place to put them is here, it will be protected from any updates

/var/lib/polkit-1/localauthority/50-local.d

So for example here is my main one, named package-manager.pkla though it extends a bit further than just package management policy's

[Install package file]
Identity=unix-group:admin
Action=org.debian.apt.install-file;org.debian.apt.update-cache;org.debian.apt.install-or-remove-packages;org.debian.apt.upgrade-packages
ResultActive=yes

[Install package synaptic]
Identity=unix-group:admin
Action=com.ubuntu.pkexec.synaptic
ResultActive=yes

[Change add repo]
Identity=unix-group:admin
Action=com.ubuntu.softwareproperties.applychanges;org.debian.apt.change-repository
ResultActive=yes

[usbcreator format]
Identity=unix-group:admin
Action=com.ubuntu.usbcreator.format
ResultActive=yes

[Install bootloader]
Identity=unix-group:admin
Action=com.ubuntu.usbcreator.bootloader
ResultActive=yes

[Add users]
Identity=unix-group:admin
Action=org.freedesktop.accounts.user-administration
ResultActive=yes

Note that starting in 12.04 the group used for "admin" user should be changed to sudo, ie.

Identity=unix-group:sudo

Also note that actions can be strung together per section, no spaces, use a ; in between id's

🌐
Narkive
linux-il.linux.org.il.narkive.com › VdLZPo7s › how-to-disable-policykit
how to disable PolicyKit?
- Normal users, were not affected at all. - However, laptop users could enable it on boot. Disable the legacy /etc/init.d/network (so they don't fight over the interfaces) This would enable them to roam easily between wireless networks (a must have for mobile users).
🌐
GitHub
github.com › cockpit-project › cockpit › issues › 13947
Optional Feature: --disable-polkit · Issue #13947 · cockpit-project/cockpit
April 22, 2020 - For embedded devices it would be useful if Polkit could be disabled. Since Polkit is dependent on mozjs. mozjs is about 25MB on the target device. Would this be a good or bad feature? Or does it have a chance to be included in the master...
Author   cockpit-project
🌐
Ubuntu
manpages.ubuntu.com › manpages › bionic › man8 › polkitd.8.html
Ubuntu Manpage: polkitd - PolicyKit daemon
December 8, 2015 - Please send bug reports to either the distribution or the polkit-devel mailing list, see the link http://lists.freedesktop.org/mailman/listinfo/polkit-devel on how to subscribe.
🌐
Manjaro Linux Forum
archived.forum.manjaro.org › technical issues and assistance
How to completely remove /disable Policykit? (It's useless anyway.) - Technical Issues and Assistance - Manjaro Linux Forum
July 30, 2017 - Ahoy and thanks for reading. I am looking for a way to completely get rid of policykit while keeping all the nice things that pretend they depend on it. If you wonder why i consider it useless: try the following on an unprivileged console: xinput list (note the id of your keyboard) xinput test id_of_your_keyboard then launch something that makes polkit ask you for your password and see every keystroke recorded on the console.
🌐
Super User
superuser.com › questions › 1713493 › ubuntu-20-04-desktop-too-many-polkit-prompts-authentication-required
policykit - Ubuntu 20.04 desktop too many polkit prompts - Authentication required - Super User
March 29, 2022 - Not exactly, since the solution is more of a hack where its all disabled or we have to add exceptions by hand. Am looking at a script or a gui tool that monitors a prompt and allows adding exception permanently when the prompt appears first time. ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 0 Can not to reach (ping,ssh) Ubuntu host from local network (WLAN).
🌐
ArchWiki
wiki.archlinux.org › title › Polkit
polkit - ArchWiki
(Discuss in Talk:Polkit) The following rule disables suspend and hibernate for all users.