2

I have a clean-installed Ubuntu server without X11, no desktop environment like ubuntu-desktop, gdm, lightdm. I installed the tightvnc, qemu-kvm and prepared a guest vm via the command lines with virt-install pointing to use vnc at port 5900.

I do understand the necessary of having desktop environment on the host (in this case, Ubuntu server) for connecting and monitoring the host itself.

But I don’t understand if the desktop environment for the host is necessary for the case connecting only to the guest vm. I think it seems to be duplicated GUI for both host kvm and guest vm.

I checked some guidelines and they pointed to the vncserver with X11. But how does it have any relationship with the setting of vnc on kvm since the netstat is telling me 2 ports are being listerned by qemu-kvm (5900) and vncserver (5901)?

So far I can connect to the port 5901 and of course receving graphic GUI message about lacking of X11. But connecting to the port 5900 from another PC over LAN still get the stuck at the state “connecting”.

How can I enable the vnc for guest vm without installing the desktop environment for my Ubuntu server 18.04.2?

2 Answers 2

4

OK, finally I can get it worked so I post the answer here just in case someone needs it.

In short, I don't need to install both the vncserver and desktop environment on Ubuntu server in order to use vnc with KVM guest. The KVM does come with the built-in vncserver and hence it has different configuration. I had a big mistake when trying to install and config the vncserver for the host Ubuntu server since it's totally useless in my case.

To enable vnc for KVM, just enabling the following 2 options in /etc/libvirt/qemu.conf

vnc_listen = "0.0.0.0"
vnc_password = your-password

My 2nd mistake was not to set the password for vnc so the vncviewer always failed to connect, even in the case the password was set to empty.

After that, enabling the following option in /etc/libvirt/libvirtd.conf

listen_tcp = 1

And of course restarting the libvirt service again

service libvirtd restart

Now the KVM guest can be installed via the command line similar to:

virt-install [...] --graphics vnc,port=5900,listen=0.0.0.0

From the client PC that you want to connect with Ubuntu server, make sure to forward the port of vnc similar to:

ssh -v -L 5900:127.0.0.1:5900 -N -f 192.168.1.100

The address 127.0.0.1:5900 is the default localhost address for vnc on the Ubuntu server. I don't enable the firewall so it's not necessary for me to add the port 5900 to the firewall.

Finally, open the vncviewer on client PC and connect to vnc://127.0.0.1:5900, then provide the password and enjoy your machine.

1

As long as I know, KVM uses 2 ports, which seperates input(which simulate keyboard and mouse), and output (screen). It's often better idea to use SSH connection instead, if you only use terminal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .