How to Access Your Raspbian Desktop on the Raspberry Pi from Another Computer

When I want to play around with the Raspberry Pi, I typically end up on the floor in front of the TV (my “spare” monitor). I’m surrounded by HDMI and LAN cables, a power adapter and mouse/keyboard receiver wires, and if I don’t clean them up the 2 yo will make me wish I had when he gets up the next day. Fortunately, I’ve found a better option.

In only a few relatively easy steps, you can create a setup that allows you to access the Raspbian desktop on your Pi from any machine in your house.

Goal

Access the Raspbian desktop from other machines in your house / on your network.

Steps

In order to make this work, we’ll need to cover a few things:

  • Serving Pi: Setting up an app that “serves” the desktop to other machines
  • Consuming Pi: Setting up an app on another machine, to connect to the Pi
  • Finding More Pi: Configuring a static IP address so you can always find your Pi
  • Pi on the Go: A few considerations for remote access (outside of your house)

Serving Pi

serving apple pie

If you’re going to connect to the Raspbian desktop on your Pi, the Pi needs to run a program that can serve the desktop to other machines. This process is commonly referred to as virtual network computing, or VNC. For Windows users, it’s similar to Remote Desktop, but RDP is specific to Windows. VNC is more general.

I installed a VNC app called TightVNC, as suggested in the Raspberry Pi’s VNC tutorial.

To install the app, just run this command from a terminal on your Pi:

sudo apt-get install tightvncserver

Skip the part about “xtightvncviewer” and then follow the rest, all the way to the bottom. It’s not very useful to install the server if you have to login every time and start it up manually. The tutorial shows you how to make sure it boots up each time you start the Pi.

Consuming Pi

plum-cake-984102_1280

Once the server portion is setup on the Pi, you need to install an app that can access it.

There are links at the bottom of the tutorial for each of the major operating systems. I happen to be using a Mac OS, so I downloaded and installed “RealVNC”.

To connect, you’ll need the Pi’s current IP address on your network, which you can find several different ways. For me, hostname -I in a terminal window returned the IP address. The command ip -f inet addr also worked, albeit showing more info. The address will probably show under “wlan0” for wireless connections, or “eth0” for wired.

This leads to another issue though. Most routers will dynamically assign an IP when a device (re)connects to the network. Like the last step, it’s not very useful to set all this up if you have to login to the Pi each time to check the IP address.

Finding More Pi

fruit-tart-1090186_1280

Following the article How to give your Raspberry Pi a Static IP Address, you should be able to configure a static IP address.

Basically, you’ll have to run ifconfig and netstat -nr to look up a total of 5 pieces of data, which you can then edit into the “/etc/network/interfaces” file.

I was able to assign a single IP address to my Pi, and it’s retained the address through quite a few restarts. No more cables and wires all over. I replaced the LAN cable with a small usb wifi dongle, and now I’ve literally just got the Pi sitting behind the TV plugged into the wall, out of the way.

Pi on the Go

pie restaurant

Accessing your Pi from outside of your house is a different beast. If you can get to it from outside your house, then so can anyone else (potentially). So you have to carefully consider security.

One option may be to just use an app like TeamViewer. It’s free for personal use (scroll to the bottom of the page), and the connection is encrypted. It works over a regular Internet connection, so you shouldn’t have to configure your firewall. Either wait for an ARM-based version, or consider a workaround. This option eliminates the need to know your home’s IP address.

Another option is probably foolish, but since VNC typically runs over port 5900, you could just open that port on your firewall, and forward all traffic (you’ll need to play around with your router to see where the settings are to route incoming requests) to the IP address you setup earlier for your Pi.

Your ISP dynamically changes your house’s IP address, just like your router changes machines on your internal network. So you’ll need to check into getting a static IP from your ISP (probably expensive), or using a service like No-IP and DynDNS that tracks your changing IP address and provides a free URL for you to use. I’ve used No-IP before and had good luck with the service. Their software probably won’t install on your Pi, but you could conceivably run it from another machine on your network, which would update your IP address, and then have your firewall forward anything coming into 5900 to the Pi. Even if you get the connection working, you’ll want to secure your transmissions somehow, probably by setting up SSH and tunneling your VNC connection through that.

Again, remote access is beyond the scope of this post and my own expertise. Just food for thought.

Subscribe to Weekly Updates!

Get an email with the latest posts, once per week...
* indicates required