CentOS and KVM: Setup VNC server on the hypervisor
After a complete installation of the KVM hypervisor, libvirt and the rest of utilities, VNC server can be used to remotely access the graphical console (aka Video output) of the VMs via the Virtual Machine Manager.
But by default VNC will not run:
Code:
# chkconfig --list | grep vnc
vncserver 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# chkconfig --levels 5 vncserver on
# chkconfig --list | grep vnc
vncserver 0:off 1:off 2:off 3:off 4:off 5:on 6:off
Also it needs minimal configuration to run:
Code:
# service vncserver start
Starting VNC server: no displays configured [FAILED]
# vim /etc/sysconfig/vncservers
...
VNCSERVERS="2:admin"
VNCSERVERARGS[2]="-geometry 1024x768"
Uncomment the last two lines to be similar to above two. The first one tells to connect as "admin" user on port 2 (it was the default) and start with a resolution of 1024x768.
Next, "vncpasswd" utility needs to be used as "admin" user to generate login passwords before the "vncserver" service is started:
Code:
# su - admin
$
$ vncpasswd
Password:
Verify:
$ pwd
/home/admin
$ ls .vnc/
passwd
$ logout
# service vncserver start
Starting VNC server: 2:admin
New 'KVM4vSRX:2 (admin)' desktop is KVM4vSRX:2
Starting applications specified in /home/admin/.vnc/xstartup
Log file is /home/admin/.vnc/KVM4vSRX:2.log
[ OK ]
# lsof -Pni :5902
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Xvnc 21540 admin 6u IPv4 10386371 0t0 TCP *:5902 (LISTEN)