X11vnc is a great way to remote access a CentOS 7 or 8 machine with a GUI. I will outline the steps to get this accomplished and use x11vnc as a service to start with the GUI.
- Install the appropriate epel release.
- Install x11vnc
- Set the vnc password for the appropriate user. This can be done for root user as well.
Note where the password is stored. In this case which is typical it is stored to /root/.vnc/passwd
- Create the vnc service. Us your favorite text editor, vi or nano and create the file vi /lib/system/system/xaavnc.service
The parameters are as follows:
ExecStart=/usr/bin/x11vnc -display :0 -auth guess -loop -forever -safer -shared -ultrafilexfer -bg -o /var/log/x11vnc.log -rfbauth /root/.vnc/passwd -rfbport 5900 -http -users moore -nowireframe
**Notice the password file path is set to the password file created when you set the vnc password.
Save the file.
- Enable and start the x11vnc service you just created: systemctl enable x11vnc.service && systemctl start x11vnc.service You can check the service status with systemctl status x11vnc
- Now open the firewall ports for the port specified in the service. One note, depending on the services you have listening, you may need to adjust the listening port in your service file. The usual port is 5900 but on a KVM host I had to make the port a different number. 590X. When you connect, if you are using any port besides 5900 you will need to open the appropriate ports and specify it on the client.
firewall-cmd –add-service=vnc-server –we don’t need to specify the port here because the service file provides that information.
That’s it. You should be able to connect to your desktop with out a problem. If you do encounter a problem, please post in the forums and I will try to help you if I can.