fixing polkit authentication when accessing libvirt as non root user remotely
kvm command line tool virsh when access remotely will ask for authentication, which is quite annoying at times to fix this we can add a polkit rule to allow users to access libvirt daemon
==== AUTHENTICATING FOR org.libvirt.unix.manage ===
System policy prevents management of local virtualized systems
Authenticating as: cipher
Password:
==== AUTHENTICATION COMPLETE ===
Id Name State
----------------------------------------------------
#cd /etc/polkit-1/rules.d/
#ll
-rw-r--r--. 1 root root 974 Aug 4 2017 49-polkit-pkla-compat.rules
-rw-r--r--. 1 root root 326 Jan 15 2014 50-default.rules
#touch 80-libvirt-manage.rules
add below code to the file
polkit.addRule(function(action, subject) {
if (action.id == "org.libvirt.unix.manage" && subject.local && subject.active && subject.isInGroup("wheel")) {
return polkit.Result.YES;
}
});
save and restart polkitd daemon
# usermod -aG libvirt cipher
#newgrp libvirt
Now we can access libvirt without authentication.
$virsh list --all
Id Name State
----------------------------------------------------
Related Articles
Converting vmware vmdk images to kvm qcow2 images
Red hat certifications are one of the most demanding in the IT industry, I wanted to get started with planning working towards getting RHCE certified.
No internet on kvm guests.
After setting up bridge network on network interface enp9s0, kvm guests had issues with accessing ssh, internet.
Virt-manager error on fedora 26
virt-manager is a graphical tool to manage KVM VMs on a host, due to some dependency or reinstall of libvirt can cause virt-manager to show ImportError: No module named libvirt.