Skip to content

Instantly share code, notes, and snippets.

@kism
Created September 11, 2023 07:03
Show Gist options
  • Save kism/9fcdb56881237d5b318e2c8dc504ecf7 to your computer and use it in GitHub Desktop.
Save kism/9fcdb56881237d5b318e2c8dc504ecf7 to your computer and use it in GitHub Desktop.
So you broke sudo

So, on a vm that has polkit

Open two ssh sessions Session one, echo $$ to get the pid of your shell Session two, pkttyagent --process <pid> Session one, visudo /etc/sudoers.d/rsync or what ever other command you want as root Session two, authenticate as the user

You will notice the prompt is the same as the one when you try start/stop/restart/reload a systemd service

Select a user that is allowed in polkit, anyone in admin or sudo should work assuming the default config Session one, your command has executed as root

$ pkttyagent --process 714042
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/sbin/visudo' as the super user
Multiple identities can be used for authentication:
1.  <user>
2.  <user>
3.  <user>
Choose identity to authenticate as (1-3): 3
Password:
==== AUTHENTICATION COMPLETE ===
$ cat /etc/polkit-1/localauthority.conf.d/51-ubuntu-admin.conf
[Configuration]
AdminIdentities=unix-group:sudo;unix-group:admin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment