Setup x11vnc on Ubuntu18.04

1. Install Unity on Ubuntu18.04. (on 16.04, it doesn't need this step)

As Ubuntu18.04 has changed to use GNOME as its default display management, it will block VNC connect somehow ("The connection is refused by the computer"). Checked the x11vnc log, it shows:

03/05/2017 16:12:19 passing arg to libvncserver: -rfbauth
03/05/2017 16:12:19 passing arg to libvncserver: /etc/x11vnc.pass
03/05/2017 16:12:19 passing arg to libvncserver: -rfbport
03/05/2017 16:12:19 passing arg to libvncserver: 5900
03/05/2017 16:12:19 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 30259
xauth:  unable to generate an authority file name
03/05/2017 16:12:19 -auth guess: failed for display='unset'
03/05/2017 16:12:19 -auth guess: since we are root, retrying with FD_XDM=1
03/05/2017 16:12:19 -auth guess: failed for display='unset'

After tried several ways from google, I still cannot fix it. So just switch to Unity desktop. Refer to https://www.linuxbabe.com/ubuntu/install-unity-desktop-ubuntu-18-04-lts

cat /etc/X11/default-display-manager 
sudo apt update
sudo apt install ubuntu-unity-desktop //select lilghtdm
sudo reboot

2. Install x11vnc

sudo apt-get install x11vnc
sudo x11vnc -storepasswd
sudo vi /lib/systemd/system/x11vnc.service

[Unit] 
Description=Start x11vnc at startup. 
After=multi-user.target 
 
[Service] 
Type=simple 
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/USERNAME/.vnc/passwd -rfbport 5900 -shared 
 
[Install] 
WantedBy=multi-user.target

sudo systemctl daemon-reload
sudo systemctl enable x11vnc.service
sudo systemctl start x11vnc.service
sudo reboot


// make sure 5900 port is listening:
$ netstat -antp | grep 5900
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:5900            0.0.0.0:*               LISTEN      -
tcp6       0      0 :::5900                 :::*                    LISTEN      -

 

你可能感兴趣的:(linux)