3. Install VNC and RDP support for remote access if required.


VNC and RDP Remote access

Installing VNC and RDP support for remote desktop access:

X11VNC install:

Note: The default VNC server has had reported issues disconnecting clients.

We therefore install a known replacement from source:

As the broadcast user:

sudo apt-get install x11vnc

sudo apt-get -y install build-essential dpkg-dev fakeroot g++ g++-7 gcc gcc-7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libaudio-dev libcilkrts5 libcups2-dev libcupsfilters-dev libcupsimage2-dev libdrm-dev libexpat1-dev libfakeroot libfontconfig1-dev libfreetype6-dev libgcc-7-dev libgl1-mesa-dev libgles1 libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libice-dev libiodbc2 libitm1 libjbig-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev liblcms2-dev liblsan0 liblzma-dev libmng-dev libmng2 libmpx2 libmysqlclient20 libopengl0 libpq5 libpthread-stubs0-dev libquadmath0 libsm-dev libstdc++-7-dev libtiff-dev libtiff5-dev libtiffxx5 libtsan0 libubsan0 libx11-dev libx11-doc libx11-xcb-dev libxau-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb1-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxmu-dev libxmu-headers libxrandr-dev libxrender-dev libxshmfence-dev libxt-dev libxxf86vm-dev make mesa-common-dev pkg-config x11proto-core-dev x11proto-damage-dev x11proto-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev x11proto-input-dev x11proto-randr-dev x11proto-xext-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xorg-sgml-doctools xtrans-dev libflac++6v5 libid3-3.8.3v5

Download http://x11vnc.sourceforge.net/dev/x11vnc-0.9.14-dev.tar.gz to the Downloads folder. (Alternative download link: x11vnc-0.9.14-dev.tar.gz)

sudo apt-get -y install libxtst-dev libssl-dev libjpeg-dev

Fix SSL support:

sudo apt-get -y install libssl1.0-dev
cd /usr/lib/x86_64-linux-gnu
sudo ln -s libssl.so.1.0.0 /usr/lib/libssl.so.10
sudo ln -s libcrypto.so.1.0.0 /usr/lib/libcrypto.so.10

Now we compile the X11VNC server:

cd
tar zxvf Downloads/x11vnc-0.9.14-dev.tar.gz
cd x11vnc-0.9.14
./configure --prefix=/usr/local CFLAGS='-g -O2 -fno-stack-protector -Wall'
make
sudo make install

Set a VNC password:

cd
x11vnc -storepasswd
Enter your chosen password and select "Y" to write the file.

Test the build and clean up:

Note: Not all VNC clients may be supported. Tested ok with TightVNC and MremoteNG.
/usr/local/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/broadcast/.vnc/passwd -rfbport 5900 -shared -nossl
While the above is running you can try to connect remotely via VNC. Press CTRL + C to stop.

Clean up:

cd
rm -rf x11vnc-0.9.14

Make the VNC server start at bootup:

sudo vi /lib/systemd/system/x11vnc.service

Paste in to the empty file the text below:
[Unit]
Description=Start x11vnc at startup.
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/local/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/broadcast/.vnc/passwd -rfbport 5900 -shared -nossl

[Install]
WantedBy=multi-user.target
Then enable the service:

sudo systemctl enable x11vnc.service
sudo systemctl daemon-reload

Reboot.

Test VNC via a remote connection using the password you set above.

NOTE: The machine must be logged in for VNC access to work.


Install XRDP for RDP access as well as VNC
(requires VNC to already be configured and working above)


To allow RDP access, we setup XRDP to connect to the VNC server.
This allows full desktop sharing via RDP.

Note: Multiple users are able to RDP to the same desktop simultaniously to the same active desktop with this configuration, which can be useful for support purposes.

sudo apt-get install xrdp

Configure xrdp to access VNC:
sudo vi /etc/xrdp/xrdp.ini
Add the following under "session types" and then put a # in front of the other session entries:
[xrdp0]
name=RDP
lib=libvnc.so
# Note that the username is ignored so we might as well not ask for it or set it to default.
username=broadcast
password=ask
ip=127.0.0.1
port=5900

Remove the (rather messy) XRDP logo from the login screen:

su root
cd /usr/share/xrdp
mv xrdp_logo.bmp xrdp_logo.bmp.old
mv xrdp256.bmp xrdp256.bmp.old
mv xrdp24b.bmp xrdp24b.bmp.old
mv ad24b.bmp ad24b.bmp.old
mv ad256.bmp ad256.bmp.old
Note: xrdp24b.bmp is 24-bit bmp file and xrdp256.bmp is 8-bit bmp.

exit
sudo service xrdp restart


Important fix for "headless" machines with no display (do not do on normal machines):

If experiencing very slow VNC response on machine with monitor diconnected.

Install a dummy video driver:
sudo apt-get install xserver-xorg-video-dummy xserver-xorg-core
sudo reboot

Create a virtual monitor device:
sudo vi /usr/share/X11/xorg.conf.d/20-intel.conf
Section "Device"
    Identifier "intelgpu0"
    Driver "intel"
    Option "VirtualHeads" "2"
EndSection
If the above doesn't work then try the following. Note that this method disables the local display completely:

Remove the file created above:
sudo rm /usr/share/X11/xorg.conf.d/20-intel.conf

Then:

sudo apt-get install xserver-xorg-video-dummy xserver-xorg-core
sudo vi /usr/share/X11/xorg.conf.d/xorg.conf

Add in everything between the ###### lines below:
######
Section "Device"
    Identifier  "Configured Video Device"
    Driver      "dummy"
EndSection

Section "Monitor"
    Identifier  "Configured Monitor"
    HorizSync 31.5-48.5
    VertRefresh 50-70
EndSection

Section "Screen"
    Identifier  "Default Screen"
    Monitor     "Configured Monitor"
    Device      "Configured Video Device"
    DefaultDepth 24
    SubSection "Display"
    Depth 24
    Modes "1366x768"
    EndSubSection
EndSection
######
sudo vi /etc/default/grub
Add "nomodeset" to the GRUB_CMDLINE_LINUX_DEFAULT line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"

sudo update-grub

Reboot.

Important: This work-around prevents anything other than a blank screen being shown if a monitor is connected.

To remove this work-around:
sudo rm /usr/share/X11/xorg.conf.d/xorg.conf
Reboot.


You should now be able to access the machine using VNC and RDP.