Accessing a virtual machine console

Sometimes you want to access a Virtual machine console, for example when you can’t access it through SSH and you want to find out why. The following post will show you how to access the console using virsh or vncviewer.

Accessing the console using virsh

Connect to the Hypervisor your Virtual Machine is running on and identify it’s ID or number:

$ sudo virsh list
 Id Name                 State
  0 Domain-0             running
$ sudo virsh console <virsh id or name>

Accessing the console using VNC viewer

We want to access the Virtual machine from a node that has access to the hypervisor the Virtual machine is running on.

First we install the following packages:

On Fedora:

$ sudo dnf -y install tigervnc xorg-x11-xauth dejavu-sans-fonts


$ sudo yum -y install tigervnc xorg-x11-xauth dejavu-sans-fonts

Then we need to figure out what are the IP and port the Virtual Machine’s VNC server is running on.

There are couple of ways to get this information:

One way is to access the hypervisor the Virtual machine is running on and run:

$ virsh domdisplay <virtual machine name or id>

For example:

$ virsh domdisplay myvm

The IP and port after the vnc:// part is our connection information. We can get the id or the name of the Virtual machine by listing the virtual machines on this hypervisor:

$ virsh list

We then connect to the machine we want to access the virtual machine from:

$ ssh -Y -C <our machine IP>

And launch our VNC client:

$ vncviewer <Virtual machine IP: VNC port>

Using the example above:

$ vncviewer

Leave a Comment