Remote Access your Raspberry Pi Raspbian GUI on Mac using VNC

If you have another computer in your house, you can set up a remote connection to your Raspberry Pi using a Virtual Network Computing server, or VNC. This means you will have full access to the Raspbian OS with the graphical user interface in a shared window on your computer. This is particularly useful if you don’t have a screen or keyboard and mouse for the Pi. Once you have the VNC server installed on the Pi, no internet connection is required either, so you can remote access your Pi from anywhere, with a direct ethernet connection to your laptop. In this set of instructions I am going to show you how to do this in four steps with Mac OS.

I have adapted this tutorial now to assume that you don’t have a mouse and screen at all, however the tutorial does assume that you have already installed Raspbian OS on your Pi, and can connect the Pi to the internet – the easiest way to do this is to connect the Pi with an ethernet cable to your router.

For this tutorial you will need an internet connection to setup a VNC server on the Raspberry Pi, but you only need to do this once and from then on you just need a local network connection in order to use remote VNC sharing.

Required Materials:

  • A Raspberry Pi with Raspian installed
  • A Mac (OS X)
  • An internet connection for package installation only
  • A router
  • 2 ethernet leads

   

1. Use ssh to establish a connection to the Pi

Power on the Pi and connect both your laptop/desktop and Pi to your router with an ethernet lead.

On your mac bring up spotlight (shortcut is cmd+space) and type in “terminal”, the application will show up, open it so we can use the command line on Mac. Your new terminal window should look something like this:

new-terminal

Because we have a wired connection, we can ssh in to the Raspberry Pi by entering the following line in terminal:

ssh pi@raspberrypi.local

ssh-in

 

Press return and you will be prompted to enter the password for your Pi – if you haven’t set one up, the standard password is “raspberry”, enter it and press return:

password-entered

Great you are in!

alternatively:

If you have a wireless network at home, and a wireless peripheral/dongle on your Pi (this also needs to be set up)  you can ssh in without a wired connection, granted that you know the ip address of the Pi, mine seems to always assign itself to .17, but yours will likely be different:

ssh pi@192.168.0.17

Your Pi ip address will be along the lines of pi@192.168.0.xx. Terminal will ask you to type in the password for your Pi – the default password unless you have changed it is “raspberry”, type it in and press return. You can continue with installation.

2. Install the VNC server package on the Pi

On your laptop, type the following lines into terminal and allow the processes to complete at each stage, the Pi will need access to the internet for this step, which is why we needed to connect it to the router:

sudo apt-get update

sudo apt-get install tightvncserver

This will take a little time to install the package, so maybe set yourself up with a beverage whilst you wait. I like to run a sudo reboot after any package installation – if you do that, you will need to ssh into your Pi again. Once you have completed the packaged installation, you no longer need the router connection – a single ethernet lead link to your laptop/desktop will suffice.

 

3. Run the VNC server on the Pi

Now we can set up the VNC server on the Pi by entering a couple more lines into Terminal:

vncserver :1 -geometry 1920×1080 -depth 24

vnc-server-copy

nb: you may find that 1920×1080 gives a resolution that is a little too high for running the Raspian desktop in a window – I find 1024×680 is quite a comfortable setting for my eyes.

You will be prompted to enter a pairing password, so type it in and remember it. I just used “raspberry” again.

Multiple servers can be setup for remote viewing/access, but the more you set up, the more system resources will be used, and this is additional to the Pi just running the Raspian GUI as it would under normal circumstance. We can optionally close the standard Raspian GUI session to save some resources using the line:

sudo service lightdm stop

stop 0 copy.png

There are some more details and an explanation on how to automatically start a VNC server on boot for the Pi here: https://www.raspberrypi.org/documentation/remote-access/vnc/

 

4. Start a remote VNC session on your Mac

This is really easy, because the Mac comes equiped with VNC software, so we don’t need to install anything new. From finder press cmd+k to bring up a new Server prompt. In the server address field type:

vnc://raspberrypi.local:5901

mac-server-select-copy

The 1 in “5901” corresponds to the “X” session number you want to link to. You will then be prompted asking for the pairing password you set up previously. You should now have a window pop up with access to the desktop on your Pi!!

nb: If you used a wireless connection and used the Pi ip address to ssh in, you will probably need to enter it into the server window on your mac as well, in which case you would enter something like vnc://192.168.0.17:5901 instead.

remote-pi-copy

You can find some more information on doing this by following this link to the official Raspberry Pi site: https://www.raspberrypi.org/documentation/remote-access/vnc/mac.md