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.)
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.
I’m sure most of the instructions herein will be the same.
As it turns out, this is untrue. Here are a few tips and tricks detailing how things change.
So, the initial setup and getting Wi-Fi working was almost identical, but getting the USB audio card to work was very different. Instead of following the instructions in the first post, the instructions by JoTil in this forum thread are what you need. Go to /usr/share/alsa/alsa.conf and replace
and your USB audio card should work (follow the instructions in the old post to verify that!).
When it comes to installing Shairport Sync the instructions also change slightly, because Jessie supports systemd and Wheezy only supports System V. Here are the new steps:
This is the process I followed to get a working AirPlay receiver!
First off, assemble your Raspberry Pi (put the case on, plug in the Wi-Fi and sound adapters, and plug in an Ethernet cable). I highly recommend connecting a keyboard (USB) and a monitor (HDMI). This is going to just be a temporary thing until you’ve got everything configured, so you could just unplug your Blu-Ray player and hook it up to your telly (this is basically what I did).
Now you’re going to download Raspbian, which is the official Linux for the Raspberry Pi. I got Raspbian Wheezy from the official downloads page, as opposed to Raspbian Jessie, which is a more recent version. I choose Wheezy because it boots to the command line instead of to GUI, and I thought that for what I was doing, that would be a more sensible choice; I’m sure most of the instructions herein will be the same.
After I downloaded Raspbian Wheezy, I unzipped the resulting file and followed the instructions for creating an SD card using OS X. I used Disk Utility and worked out what the disk number of the SD card was by looking at the entry for ‘Device’ in the table underneath the usage chart, and then I ran the following in Terminal.app, where the n in rdiskn should be replaced with whatever the disk number you find is:
This whirred away with no outputs to the Terminal until the process had finished, so don’t be alarmed if nothing appears immediately; just be patient.
I then took the SD card out and put it into the Raspberry Pi. I connected an Ethernet cable to the Pi and to my router, so that it would have an Internet connection. I initially did this with no connected monitor, but I found it too frustrating for words not to be able to see what was happening, so I also plugged in a USB keyboard and a HDMI display. Then, I plugged the power cable in and watched everything boot.3
The username and password for your Raspberry Pi are, by default, pi and raspberry. On my first boot, I was logged in without needing these, but it’s worth knowing what they are for now. You ought to see the configuration screen upon your first boot, and so I followed these steps to configure my machine, expanding the filesystem, setting a locale and a timezone, and changing the name of my Raspberry Pi on the network. Then I rebooted, and logged in using the username and password, ending up at the shell.
At this stage, I got bored of being in front of my TV, so I unplugged the USB keyboard and the HDMI display and headed to my iMac, where I brought up my Wi-Fi router’s list of devices on the network. Upon learning the IP address that my Raspberry Pi had on the network, I was able to run
The Ethernet cable was trailing across my living room, so configuring Wi-Fi was the next thing to do. Fortunately, once you have the drivers for your Wi-Fi adapter set up correctly, this is pretty easy5! The Wi-Fi adapter I bought isn’t supported out-of-the-box, but a trip to Stack Exchange revealed that this wasn’t a problem, courtesy of this post by MrEngman on the Raspberry Pi forums. To get the adapter working, simply do
pi@RaspberryPi ~ $ uname -a
Linux RaspberryPi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux
to find your version number (in this case, it’s 3.18.11-v7+ #781) and then, on MrEngman’s post, find the .tar.gz filename which corresponds to that number. Then, I just scrolled to the bottom of his post to find out that I needed to run
tar xzf 8188eu-v7-20150406.tar.gz
to get my Wi-Fi adapter working. I rebooted the system before continuing, just to be sure.
I then rebooted and tested the output by plugging my EarPods into the sound adapter and then running
speaker-test -t sine
If you don’t hear a tone, it’s not properly configured.
Finally, I installed the tools I needed to get AirPlay running on my Raspberry Pi. I initially used this AirPlay tutorial and this AirPlay tutorial to get it working by installing a GitHub project called Shairport into ~/airplay, which is currently not under active development. I AirPlayed some audio to the Pi, and it worked fine, which made me very happy! However, when I tested using iTunes to play through the Pi and my iMac simultaneously, the two audio tracks were not in sync. As such, I went looking for ways to make AirPlay synchronise the playback.
I found my salvation in the form of Shairport Sync, which is a fork of Shairport with the added benefit that it is in active development6. Here are the steps I took to install it7 (including a line which checks whether systemd or System V is the way forward on your machine8), which come from the project’s Readme.
I then configured Shairport Sync so that when I AirPlayed to my Raspberry Pi it would appear with a different name. Since I’m going to hook this up to a Sony Hi-Fi, I ran
sudo nano /etc/shairport-sync.conf
before uncommenting the first line under general so that it read
name = "Sony Hi-Fi";
before the rest of the settings. Then I rebooted the Pi, and Shairport Sync automatically ran on startup and let me AirPlay my music to it, perfectly synchronised with my other speakers.
Finally, I decided to make a copy of my SD card so that if I messed things up in the future, I can roll back to being satisfied with my progress. To do this, I put the SD card back in my iMac, and then (following the advice of this guide) used Disk Utility to work out what disk number it was (the n in rdiskn), and then did
sudo dd if=/dev/rdiskn of=~/Desktop/pi.img bs=1m
I might be going crazy, but a look at the SanDisk website doesn’t seem to show this product as a current part of their line-up, with only a microSD XC card available; hence the link to a shop rather than the official product page. ↩
I later found out that this adapter doesn’t work without a significant amount of coaxing. Don’t worry, I’ll give the details of how I coaxed it herein! ↩
Watching all the console outputs whizz past on Linux really does make you feel like you’re in The Matrix. ↩
A lot of Raspberry Pi guides will tell you that you need to enable SSH yourself, but this appears to be false in newer versions of Raspbian. ↩
Some guides, such as this one, will tell you to edit /etc/network/interfaces to get Wi-Fi up and running, but again, this appears not to be necessary in newer versions of Raspbian. ↩
Shairport Sync was last updated in October 2015, three months before this was written. ↩
Note that I did this having already followed the tutorials to install Shairport, so it’s possible that this will not work without having done that. I think it should be fine, but I might be wrong! ↩
I think Raspbian Wheezy requires the System V method whereas Raspbian Jessie can use the systemd method, so this part might be a little different if you went modern and plumped for Jessie. ↩
It used to be that installing PlexConnect as a package on a Synology would let you choose whether to hijack the Trailers app or the WSJ Video app, and then it would just work. Unfortunately, nowadays, choosing WSJ Video doesn’t work; something is clearly wrong in the default settings of the app. Here’s how I went about rectifying that. (The below assumes that you’ve been able to get PlexConnect working before, so it assumes that most of the initial setup, you’re already familiar with.)
Firstly, I generated some SSL certificates, following the advice of this forum post1 and running the following two commands in the Terminal:
Then, I stopped the PlexConnect package from running and SSHed into the DiskStation as root. I copied the Settings file from PlexConnect to the user-facing part of my Synology, by running the following commands:
When I moved into my new flat, I got an Apple TV. I love it so much — it connects to the TV in the flat, letting me watch Netflix and YouTube videos, or videos that are in my iTunes library. It also lets me use AirPlay, which is baked into Apple devices; if I’m watching a video on my iPad, I can tap a button and suddenly the video I was watching appears on my television, letting me watch videos either on the sofa or as I wander around doing housework.
This is especially useful for me, because there are a couple of video sources on my iPad that I can’t get on the Apple TV. The first requires some context: I have a Synology NAS1, which is running Plex Media Server2 By running Plex on my Synology, I can watch any of the videos I have downloaded on my iPad (or my Mac, or any other device). But, there isn’t a Plex app for Apple TV, so I have to use the iPad to watch this content and use AirPlay if I want to watch it on my television.
The second video source is Netflix. While the British Netflix is available through the Apple TV, sometimes it’s useful to be able to connect to Netflix in other regions because the video content there is different (the US has many more US sitcoms, for instance; the Dutch site has a lot of blockbusters). I can’t do that through the Apple TV, so I had to connect the iPad to my VPN (Private Internet Access) and then the iPad to watch it.
It’s a fairly minor inconvenience, but I got more and more annoyed that whenever I wanted to watch videos from Plex or other regions’ Netflix I had to use the iPad. Using my iPad to AirPlay the video to the Apple TV worked fine, but it was annoying if the iPad was running low on battery, or even if I was browsing Reddit and accidentally clicked a link to a video. Heck, even visiting a website with video ads can replace the show you’re watching with something completely different!
Fortunately, however, it’s possible to get your Apple TV to play video from both the sources I list above, and this blog post shows you how to do that. Before we start, I’m assuming that you already have Plex Media Server running on your Synology (and therefore that you have configured your Synology to allow third-party packages). Also, this process caused me a great deal of stress and occasionally went very wrong for me, so make notes of the initial state and don’t blame me for anything that happens as a result of these instructions; you do this at your own risk.
Getting Plex onto the Apple TV
The first step is to visit this very useful post on the Plex forums, which will take you through the process of installing and running PlexConnect on your Synology. It looks scarier than it is, but honestly it’s about five minutes’ work to get everything working. This process neatly addresses the first of my two gripes about the Apple TV, and I can’t imagine I’ll ever miss the WSJ Live app. It’s worth noting that installing PlexConnect will cause your Apple TV to stop receiving updates by default, but this can be changed (I’ll leave how to do so as an exercise for the reader).
Getting US Netflix onto the Apple TV using OpenVPN
Once you’ve got PlexConnect working, if you want to get US Netflix as well, there are a couple of ways to do that. The way I did it was predicated around my choice of VPN, Private Internet Access; they allow connections through OpenVPN but don’t offer what’s called a Smart DNS3, which meant I had to get a little clever. The first thing to do is to visit your Wi-Fi router’s settings and make your Apple TV’s IP address permanent4. Then, on your Apple TV:
Open Settings, then General, then Network, then the name of your network (as before).
Select Configure IP, then select Manual.
Don’t change the first two IP addresses.
Change the IP address for Router and DNS to the IP address of your Synology (the second one should already be set).
Then, on your Synology:
Open Control Panel and head to the Network, before opening the ‘Network Interface’ tab.
Create VPN profile.
Select whichever type of VPN you have. OpenVPN is the best choice if your VPN supports it.
Fill in the details, and make sure you tick the box that allows other devices to use the Synology’s internet connection.
Connect the VPN
Go back to the Apple TV, and open the Netflix app; the content shown should be from the region that you’re VPN’d to. However, there’s an important caveat here: as far as I can tell, PlexConnect doesn’t work when the Synology is connected to a VPN if you’ve followed these instructions. So: disconnect the VPN if you want to watch Plex content, and reconnect it to watch Netflix in other regions.
So, there you have it. You can watch US Netflix content from your sofa using a VPN and PlexConnect. Go forth and binge Parks and Rec!
A NAS is a box that has some hard drives in it and connects to your router. Once it’s connected, anyone on your network can access the drives, and you can install some simple programs on it that are also accessible to people on your network. One of these programs is Plex, which basically takes video files and organises them for you. But, if you didn’t already know all that, this blog post might not be ideal for you…. ↩