Screen sharing with Ubuntu

Recently, at work, I started using an Ubuntu machine. While most of the setup of the machine was fairly easy, there’s a dearth of information online detailing how to screen share properly so that you can work on such a machine remotely. What I wanted to do was replicate Apple’s Back to my Mac functionality, but connecting to an Ubuntu machine from my Mac — this post details how I went about achieving that.

Firstly, you’re going to want to go into the Terminal and type vino-preferences, and then select ‘Allow other users to view your desktop’ and ‘Allow other users to control your desktop’. Then, choose an eight-character password for screen sharing — this isn’t terribly secure, but we’ll beef it up later.

Next, we will use dconf-editor to remove the requirement for encryption built into Ubuntu (otherwise, macOS won’t let you actually share screens). Install and run dconf-editor by going to Terminal:

sudo apt-get install dconf-tools

Then follow the instructions on Interweb World to configure it correctly for macOS. (You should be able to start at Step 3.)

Next, we’re going to make sure that we can only share the machine’s screen when we SSH into it.

gsettings set org.gnome.Vino network-interface 'lo'

What this does is make sure that the only screen sharing connections that can be made to your computer are from the localhost; i.e. people already connected to your machine. This will mean you have to SSH into your machine before you can share the screen — much more secure than VNC’s security, but compatible with macOS. (Credit to Ask Ubuntu for this tidbit.)

In Terminal, SSH to your machine by typing:

ssh -L 12345:localhost:5900 username@remoteIP

In this example, three of the bits of text could change: username is your username on the machine you’re trying to access remotely, remoteIP is the IP address (or URL!) of the machine you’re trying to access, and 12345 is a port number you’ll need later (you can choose your own if you like!).

When you successfully SSH into the machine, go to Finder, and select ‘Connect to Server…’ in the ‘Go’ menu. Connect to vnc://localhost:12345, where that’s the port number you chose before. This should then share your screen successfully and securely.