Ubuntu 18.04.1 LTS Can't Enable Screen Sharing

When trying to enable "Screen Sharing" under the "Sharing" section of the system settings I can click on the "ON/OFF" slider but it will not stay set to "ON". I can set the "Sharing" slider to "ON" and the "Remote Login" slider to "ON" but not the "Screen Sharing" one. Am I missing something?

Running Ubuntu 18.04.1 LTS and have attempted this both on GNOME on xorg and GNOME Flashback


This happened to me, here is how I corrected it.

My network showed "wired-unmanaged"; to correct this, I had to do the following:

Note: If you're interested in a set of commands to copy/paste into your terminal, I'd encourage you to review these instructions first, before running the commands listed at the end of this answer.

  • cd /etc/NetworkManager
  • save NetworkManager.conf to NetworkManager.orig (as a backup)
  • sudo vi NetworkManager.conf

    Change managed=false to managed=true

    New file looks like this:

    [main]
        plugins=ifupdown,keyfile
    [ifupdown]
        managed=true
    [device]
        wifi.scan-rand-mac-address=no
    
  • sudo service network-manager restart
  • cd /etc/netplan
  • sudo vi 50-cloud-init.yaml

    Add this line just below network:

    renderer: NetworkManager

    New file looks similar to this (ensure the renderer line is indented as shown):

    network:
        renderer: NetworkManager
        ethernets:
            enp3s0:
                addresses: []
                dhcp4: true
    version: 2
    
  • save
  • sudo netplan apply
  • I had then to restart the computer for this to be effective.
  • After restart the network will now show "wired-connected"
  • Then you can go to Settings » Sharing » Screen Sharing
    • You should now be able to toggle Screen Sharing to ON
    • Under Networks (bottom of dialog), toggle those ON as well

Commands

If all you're looking for is some terminal commands, and you haven't made any manual changes to the files mentioned in the instructions above, running the commands below should take care of the file modifications:

cd /etc/NetworkManager
sudo cp NetworkManager.conf NetworkManager.orig
# Change NetworkManager.conf: 'managed=false' to 'managed=true'
sudo sed -i 's/managed=false/managed=true/g' NetworkManager.conf
sudo service network-manager restart
cd /etc/netplan
# Ensure networks are managed by NetworkManager
# Whitespace in this command is important!
sudo sed -i '/^network:/a \    renderer: NetworkManager' 50-cloud-init.yaml
sudo netplan apply
# Restart your machine, or uncomment one of the lines below:
#sudo shutdown -r now
#gnome-session-quit --reboot

After you run these commands, refer to the final step above to enable screen sharing.


Use x0vncserver as explained in how to start a vnc server for the actual display.

sudo apt-get install tigervnc-scraping-server

Then set a password

vncpasswd

Then start the server with

 x0vncserver -passwordfile ~/.vnc/passwd -display :0

@Jay's answer is good. The problem is caused if one disables network manager and instead use networkd in netplan. To continue to use networkd, I simply added:

/usr/lib/vino/vino-server

To my Startup Applications.