0%

VNC Configuration under Ubuntu 19.04

x11vnc is a Vitrutal Netowrk Computing service. It provides real display to remotely control another computer.

I have a PC with Ubuntu 19.04 but only want to use it remotely while keep its remote desktop environment accessibility. During this procedure, I have faced many issues but found rare information regarding Ubuntu 19.04. After I figured it out, I decided to write this article for those who are also troubled as I was.

Install X11VNC

1
sudo apt install x11vnc

create password (the following command create a encrpted password for the client to access the server )
The encryted password will be stored in the user folder.

1
x11vnc -storepasswd

You can then test x11vnc service by running following command.

1
2
3
x11vnc -create -xkb -display :0 -noxrecord -noxfixes -noxdamage -rfbauth /home/$username/.vnc/passwd -usepw
# -usepw: enable password authentication
# -rfbauth: specify the encrypted password file

Display Manager Change

Since Ubuntu 19.04 use gdm3 for display manager ( to display login interface), which has some problem with x11vnc and I found no solution online, I then changed display manager to lightdm by using following command.

1
sudo dpkg-reconfigure gdm3

You can change it to lightdm in the interface.

Start x11vnc on Boot

Afterwards, in order to make the x11vnc on boot, we need make it a service by creating this file to /etc/systemd/system/x11vnc.service.

1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -create -xkb -display :0 -noxrecord -noxfixes -noxdamage -o /var/log/x11vnc.log -rfbauth /home/diskun/.vnc/passwd -usepw -auth guess -forever
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
Restart-sec=200

[Install]
WantedBy=multi-user.target

ExecStart is the command we wanna execute. There are some new paramters.

-o /var/log/x11vnc.log : specify the log file path

-auth guess : let x11vnc autmatically determin display manager path on startup. Without this parameter, x11vnc has problem to execute before login

-forever: Keep listening for more connections rather than exiting as soon as the first client(s) disconnect.

1
2
3
4
5
6
7
8
9
10
11
# create the file
sudo vi /etc/systemd/system/x11vnc.service
# reload configuration
sudo systemctl daemon-reload
# test the service
sudo systemctl start x11vnc
# you can test the service by
sudo systemctl status x11vnc
# or login from other computer by vnc service
# if it works well, make it run on startup
sudo systemctl enable x11vnc

Connect Remotely

You can then connect your Ubuntu 19.04 remotely. In Mac OS, you can easily connect by open Finder and press CMD + K to open connect server promp and paste folllowing such kind of url:

1
vnc://192.168.2.142:5900

vnc is the protocal to be used;
192.168.2.142 is the address of your ubuntu server;
5900 is the port to your x11vnc service run on.

Hope this can help solve your problem:D

References