Andrew Mercer
on this page

Remote access to libvirt

Part of the KVM overview. Manage a remote hypervisor over SSH, use virt-manager with X11 forwarding, or Cockpit.

libvirt over SSH

virsh -c qemu+ssh://user@host/system list
virsh -c qemu+ssh://user@host/system          # interactive shell
virt-manager -c qemu+ssh://user@host/system   # GUI, run from your workstation

Add your user to the libvirt group on the remote host (permissions). Reference: https://wiki.libvirt.org/page/SSHSetup

virt-manager over X11 forwarding

ssh -X user@host
sudo dnf install virt-manager          # on the host, if needed
virt-manager --connect=qemu:///system

Troubleshooting:

  • cannot open display: echo $DISPLAY should show something like localhost:10.0. If you use sudo, copy the authority file: sudo cp ~/.Xauthority /root/.Xauthority (also fixes X11 connection rejected because of wrong authentication).
  • X11 forwarding request failed on channel 0: client side, set ForwardX11 yes (or use ssh -X) in ~/.ssh/config; server side, check X11Forwarding yes in sshd_config, restart sshd, and make sure xauth is installed.
  • Nothing to log in with: virt-viewer vm01 --display localhost:10.0 opens a single VM's console.

Cockpit

sudo dnf install cockpit cockpit-machines
sudo systemctl enable --now cockpit.socket
sudo firewall-cmd --permanent --add-service=cockpit
sudo firewall-cmd --reload

Then browse to https://host:9090.