Unable to register authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed

created at 12-05-2021 views: 5

Problem description

When deploying k8s, there is a step to set the time zone of the centos machine, the command is as follows:

timedatectl set-timezone Asia/Shanghai
timedatectl set-local-rtc 0
systemctl restart rsyslog
systemctl restart crond

The following error was reported when executing timedatectl set-timezone Asia/Shanghai:

Unable to register authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject
Error registering authentication agent: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject (polkit-error-quark, 0)

Problem analysis

This error is caused by the new version of centos 7, and the security process needs to be removed.

Solution

Many people on the Internet say that chmod 755 should be given to the directory 755. I tried it and it didn’t work, but the following method succeeded:

  • Step 1: execute the following command
getent group polkitd >/dev/null && echo -e "\e[1;32mpolkitd group already exists\e[0m" || { groupadd -r polkitd && echo -e "\e[1;33mAdded missing polkitd group\e[0m" || echo -e "\e[1;31mAdding polkitd group FAILED\e[0m"; }
    getent passwd polkitd >/dev/null && echo -e "\e[1;32mpolkitd user already exists\e[0m" || { useradd -r -g polkitd -d / -s /sbin/nologin -c "User for polkitd" polkitd && echo -e "\e[1;33mAdded missing polkitd user\e[0m" || echo -e "\e[1;31mAdding polkitd user FAILED\e[0m"; 
  • Step 2: Execute the following commands
rpm -Va polkit\* && echo -e "\e[1;32mpolkit* rpm verification passed\e[0m" || { echo -e "\e[1;33mResetting polkit* rpm user/group ownership & perms\e[0m"; rpm --setugids polkit polkit-pkla-compat; rpm --setperms polkit polkit-pkla-compat; }

Note: After executing the second step, it will automatically restart.

Result

reasult

created at:12-05-2021
edited at: 12-05-2021: