We'll use TigerVNC. RealVNC 4 that comes with Ubuntu 16.04 can also be used, but it lacks the X extensions that are required for a well behaved multi monitor setup. Also, Visual Studio Code can't run on RealVNC 4 without a special patched version of libxcb.so.1.
Ubuntu 18.04
Desktop edition
sudo apt update sudo apt install --no-install-recommends openssh-server tigervnc-standalone-server tigervnc-common sudo su cat /etc/X11/Xvnc-session mv /etc/X11/Xvnc-session /etc/X11/Xvnc-session.orig cat > /etc/X11/Xvnc-session << "EOF" #!/bin/sh export GNOME_SHELL_SESSION_MODE=ubuntu export XDG_CURRENT_DESKTOP=ubuntu:GNOME vncconfig -nowin & exec /etc/X11/Xsession vncserver -kill $DISPLAY EOF chmod +x /etc/X11/Xvnc-session exit # Start the VNC session (this must be run as your user from an SSH session after each reboot) vncserver # To stop the VNC session vncserver -kill
Server edition
sudo apt-get update sudo apt install --no-install-recommends tigervnc-standalone-server tigervnc-common ubuntu-desktopAnd then followed by the same procedure with /etc/X11/Xvnc-session and vncserver as for desktop.
For additional desktop software, I recommend using the Ubuntu Software Center, which will install Snap packages for popular desktop software.
# Install the Ubuntu Software Center sudo apt install gnome-software
Ubuntu 16.04
I only tried with server edition on 16.04, so adapt as needed.sudo apt-get update sudo apt-get install --no-install-recommends ubuntu-desktop gnome-terminal unity-lens-applications unity-lens-files gnome-settings-daemon sudo apt-get install --no-install-recommends software-center wget https://bintray.com/tigervnc/stable/download_file?file_path=ubuntu-16.04LTS%2Famd64%2Ftigervncserver_1.8.0-1ubuntu1_amd64.deb -O tigervncserver_1.8.0-1ubuntu1_amd64.deb sudo dpkg -i tigervncserver_1.8.0-1ubuntu1_amd64.deb sudo apt-get install -f mkdir $HOME/.vnc/ cat > $HOME/.vnc/xstartup <<"EOF" #!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS /etc/X11/xinit/xinitrc & vncconfig -nowin & /usr/lib/x86_64-linux-gnu/unity/unity-panel-service & /usr/lib/x86_64-linux-gnu/indicator-datetime/indicator-datetime-service & /usr/lib/x86_64-linux-gnu/indicator-keyboard/indicator-keyboard-service & unity & EOF chmod +x $HOME/.vnc/xstartup # some kde or qt apps seem to look ugly without this package sudo apt-get install kde-style-breeze-qt4 # Start the VNC session (this must be run as your user from an SSH session after each reboot) vncserver # To stop the VNC session vncserver -kill :1For Additional desktop software, I recommend using Snap:
sudo apt install snap # For example install Visual Studio Code, Chrome, and Sublime, like this sudo snap install vscode --classic sudo snap install chromium sudo snap install sublime-text --classic
Connecting
Use the TigerVNC client to take advantage of the dynamic resizing and multi-screen features. Binaries for Win/Mac/Linux can be found on their website.Open the TigerVNC menu by pressing F8, and note the shortcut keys here for full screen, minimize, etc. Copy the remote .vnc/passwd file locally and pass it to the TigerVNC client with the -PasswordFile= option to avoid having to type your password repeatedly. For example, I connect from my Windows box using a cmd file with this content:
start "" "C:\utils\vnc\vncviewer64-1.8.0.exe" "yourRemoteServer:5901" -PasswordFile=C:\utils\vnc\passwd
Secure connection
If you are connecting over the internet, you'll want to use an SSH tunnel to secure the unencrypted VNC. In that case you can start the VNC server in a mode where it only listens on localhost, and then use SSH port forwarding.vncserver -localhost=yes -nolisten tcp
Connect using your preferred SSH client, and set up port forwarding to localhost:5901, for example from your local port 5901.