Libvirt error: authentication failed: authentication failed

error: failed to connect to the hypervisor
error: authentication failed: authentication failed

If the authentication fails even after using the correct credentials, it shoud be the problem with SASL authentication configurations.

This article explains the detailed steps to resolve this issue.

Step1: Login to the host server via ssh as root.

Step2: Open the libvirt configuration file.

#vi /etc/libvirt/libvirtd.conf

Step3: Update the following parameter and save the file.

auth_tcp = "sasl"

Step4: Open the sasl configuration for libvirt.

#vi /etc/sasl2/libvirt.conf

Step5: Update the following lines and save the file.

mech_list: digest-md5
sasldb_path: /etc/libvirt/passwd.db

Step6: Install the package "cyrus-sasl-md5".

#yum install cyrus-sasl-md5

Step7: Restart libvirtd service.

#systemctl restart libvirtd

Step8: Configure the credentials for libvirt sasl.

#saslpasswd2 -a libvirt 1

That's all…