#!/bin/bash
echo $DISPLAY
export DISPLAY=:0
apt-get install -y gconftool
read -e -p "VNC Password: " -i "ubuntu" password
dconf write /org/gnome/desktop/remote-access/enabled true # So, first, enable vino
dconf write /org/gnome/desktop/remote-access/prompt-enabled false
dconf write /org/gnome/desktop/remote-access/authentication-methods "['vnc']"
dconf write /org/gnome/desktop/remote-access/require-encryption false
dconf write /org/gnome/desktop/remote-access/vnc-password \"\'$(echo -n $password | base64)\'\"
dconf dump /org/gnome/desktop/remote-access/
sudo service gdm3 restart
# Optionally you may want to do this if you want to keep the display up all the time:
dconf write /org/gnome/desktop/screensaver/lock-enabled false
dconf write /org/gnome/desktop/screensaver/ubuntu-lock-on-suspend false
dconf write /org/gnome/desktop/session/idle-delay "uint32 0"
# This doesn't seem to work remotely via ssh due to errors about the display, you can start the server remotely using the DISPLAY flag
export DISPLAY=:0 && /usr/lib/vino/vino-server
# Check to see if the server is now running
ps aux | grep X
# https://askubuntu.com/questions/4474/enable-remote-vnc-from-the-commandline