Logging into an Ubuntu desktop or using remote desktop access (such as XRDP or VNC) only to be immediately confronted by a persistent authentication dialog stating “Authentication is required to refresh system repositories” is a frustrating distraction. Dismissing or cancelling the password dialog often results in the pop-up re-appearing minutes later.
This notification originates from PackageKit (the background distribution-neutral package management abstraction layer used by GNOME Software and Software Updater). By default, Ubuntu’s PolicyKit (Polkit) security framework requires administrative authorization when background repository refreshes occur inside sessions that are classified as “inactive” or “remote”, or when standard desktop users lack fine-grained desktop privileges.
| Environment | Technical Mechanism | Resolution Approach |
|---|---|---|
| Remote Desktop (XRDP / VNC) | Session marked as remote/inactive; Polkit policy defaults to auth_admin | Create custom Polkit pkla rule to permit repo refresh |
| Standard Desktop Session | PackageKit background refresh timer triggers Polkit query | Configure org.freedesktop.packagekit Polkit rule |
| Software Updater Service Loop | apt-check or packagekitd daemon hung on lockfile | Clean apt locks and restart packagekit.service |
| Unattended Upgrades Conflict | Simultaneous cron/systemd daily update collides with PackageKit | Disable PackageKit automatic refresh if managing via APT CLI |
Method 1: Create a Custom Polkit Rule (Ubuntu 23.10 and 24.04 LTS)
Modern Ubuntu releases utilize JavaScript-based Polkit rules located in /etc/polkit-1/rules.d/ to govern system authorizations without prompting the user.
- Press Ctrl + Alt + T to open Terminal.
- Create a new Polkit rule file using a text editor with administrative privileges:
sudo nano /etc/polkit-1/rules.d/45-allow-packagekit-refresh.rules - Paste the following configuration script:
polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.packagekit.system-sources-refresh") { return polkit.Result.YES; } }); - Press Ctrl + O to save, press Enter, and press Ctrl + X to exit.
- Restart the Polkit service to load the new rule immediately:
sudo systemctl restart polkit.service
Method 2: Create a Local Authority Rule (Ubuntu 20.04 and 22.04 LTS)
Older Ubuntu LTS versions utilize key-value .pkla rule definitions inside the /etc/polkit-1/localauthority/ directory.
- In Terminal, create a custom local authority file:
sudo nano /etc/polkit-1/localauthority/50-local.d/allow-packagekit-refresh.pkla - Insert the following block:
[Allow PackageKit Repository Refresh] Identity=unix-user:* Action=org.freedesktop.packagekit.system-sources-refresh ResultAny=yes ResultInactive=yes ResultActive=yes - Save and close the file (Ctrl + O, Enter, Ctrl + X).
- Restart the PolicyKit daemon:
sudo systemctl restart polkit
Method 3: Fix Remote Desktop (XRDP) Polkit Conflicts
XRDP sessions frequently generate repetitive password pop-ups because the X-session is classified as an “any” or “inactive” seat by systemd-logind.
- Create an XRDP-specific policy rule:
sudo nano /etc/polkit-1/localauthority/50-local.d/45-xrdp-packagekit.pkla - Add permissions covering package installation, updates, and repository refreshes for remote sessions:
[XRDP PackageKit Full Authorization] Identity=unix-group:sudo Action=org.freedesktop.packagekit.* ResultAny=yes ResultInactive=yes ResultActive=yes - Save the file and restart XRDP:
sudo systemctl restart xrdp
Method 4: Disable Automatic PackageKit Refresh via Dconf / Gsettings
If you prefer to manage system package updates via the command-line (using sudo apt update) and do not need GNOME Software checking for updates in the background, disabling background checks prevents the prompt.
- In your user terminal, execute:
gsettings set org.gnome.software download-updates falsegsettings set org.gnome.software download-updates-notify false - To stop Ubuntu Software Updater from checking daily, edit the update-notifier configuration:
sudo nano /etc/apt/apt.conf.d/10periodic - Set the update interval to
0:APT::Periodic::Update-Package-Lists "0"; APT::Periodic::Download-Upgradeable-Packages "0"; - Save and exit.
Method 5: Restart the PackageKit Service and Flush Lockfiles
If PackageKit becomes desynchronised due to an interrupted APT operation, clearing stale lockfiles restores predictable behaviour.
- Stop the PackageKit daemon:
sudo systemctl stop packagekit.service - Check for any stuck APT locks:
sudo rm -f /var/lib/apt/lists/locksudo rm -f /var/cache/apt/archives/locksudo rm -f /var/lib/dpkg/lock* - Configure any pending packages:
sudo dpkg --configure -a - Start the service:
sudo systemctl start packagekit.service
Maintaining Secure Polkit Boundaries
The rules provided grant repository refresh authorization (retrieving package indices) without requiring password prompts. However, critical package installations and system modifications remain strictly protected, ensuring that unauthorized software cannot be installed without explicit root/sudo authorization.