X11vnc as a Service

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.

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.

  1. Install the appropriate epel release.

  1. Install x11vnc

  1. 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

  1. 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:

[Unit]
Description=”x11vnc”
Requires=display-manager.service
After=display-manager.service

[Service]
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
ExecStop=/usr/bin/killall x11vnc

[Install]
WantedBy=multi-user.target

**Notice the password file path is set to the password file created when you set the vnc password.

Save the file.

 

  1. 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

  1. 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.

Hostname:590X

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.

Hits: 20

Leave a Reply