RaspberryPi-VNC

From Stanford SSI Wiki
Revision as of 20:16, 27 December 2015 by Cameron (talk | contribs)
Jump to navigation Jump to search

Hate having to plug in the Raspberry Pi to an external monitor and keyboard/mouse? This guide will let you set up a remote session on the Pi directly from your laptop. You'll be able to view and interact with the Pi desktop with just an ethernet cable.

Hardware

If your computer has an RJ45 ethernet port, all you need is an ethernet cable! Notebooks without this port will need an adapter (ie. thunderbolt to ethernet or USB 2.0/3.0/C to ethernet). Note that the MacBook Pro will require a thunderbolt to ethernet adapter -- USB to ethernet will only work on the MacBook Air.

Software

Connecting to the Raspberry Pi via SSH will require an SSH client application (ie. the Unix terminal in OSX). If you're using a Windows machine, you'll have to download PuTTY from http://www.greenend.org.uk.

Windows, MAC, and Linux machines will all require a VNC viewer program. RealVNC is known to work with the Raspberry Pi VNC server, it can be downloaded from http://www.realvnc.com/download/vnc/latest/. Download the package file and open it. During the setup you'll be offered a choice of the type of installation. Deselect VNC Server, because you only want VNC Viewer. Click Continue and go ahead with the rest of the installation.

Getting Started

  1. Ensure that SSH is enabled on the Pi. This is the default out of the box setting. You can verify the setting by typing raspi-config into terminal and navigating to ssh >> enable
  2. Download a VNC server program. If you are using a MAC and don't have an external monitor/keyboard/mouse handy, you can wait to set this up after you've established an SSH connection to the Pi. You can also try installing a VNC server program via SSH on Windows but I can't guarantee that it will work (I'm not sure how internet sharing works in Windows). From the Pi's terminal type sudo apt-get update and then sudo apt-get install tightvncserver. You will be prompted to confirm installation by typing Y.
  3. Power off the pi and connect it to your laptop with the ethernet cable.

SSH for MAC/Linux

  1. Congratulations on owning a MAC. Ensure that the ethernet cable is securely connected between your computer and the Raspberry Pi.
  2. Enable internet sharing by navigating to System Preferences >> Sharing and turn Internet Sharing on for your Thunderbolt or USB ethernet connection.
  3. Plug in the wall power adapter into the Raspberry Pi, and then plug it into the wall to turn the power on. The Raspberry Pi will take a minute to boot up.
  4. Open terminal and SSH to the Pi with ssh pi@raspberrypi.local. If you're getting a host or timeout error, the Pi probably hasn't finished booting up yet. If all lights on the Pi are flashing indicating a full boot up but you're still not able to SSH, make sure SSH is enabled and type in arp -a to view your network cache. The Pi should appear as a 198.162.-.- IP address. Try using this IP to connect with ssh pi@<IP ADDRESS>
  5. You’ll be prompted to verify you’re trying to login to the Raspberry Pi. Type “yes” and press return. Type the password, which is “raspberry” and press return. Boom! You’re logged into your Raspberry Pi.

SSH for Windows

  1. Buy a Mac. If that doesn't work, ensure the ethernet cable is securely connected between your computer and the Raspberry Pi.
  2. Plug in the wall power adapter into the Raspberry Pi, and then plug it into the wall to turn the power on. The Raspberry Pi will take a minute to boot up.
  3. On your computer, open Putty and enter the Host Name as raspberrypi.local and press open.
  4. If everything goes according to plan, you’ll be prompted with a security prompt. Press “Yes”
  5. This will open a terminal and ask for a Username and Password. The username is “pi” and the password is “raspberry“. After entering the credentials, you’ll get logged on to the Raspberry Pi terminal.

Setting up VNC

  1. We now need to run the VNC Server, so enter the following command into your SSH window: vncserver :1. If you haven't downloaded the VNC server application, follow step 2 of [Getting Started]. If you're using Windows, I can't guarantee that the tightvncserver will download over your SSH connection.
  2. If this is the first time you've started the VNC server, you will be prompted to enter and confirm a password. It would make sense to use “raspberry” for this, but passwords are limited to 8 characters, so I use “raspberr”. Note that this is the password that you will need to use to connect to the Raspberry Pi remotely. You will also be asked if you want to create a separate “read-only” password – say no.
  3. The VNC server is now running and so we can attempt to connect to it, but first we must switch to the computer from which we want to control the Pi and setup a VNC client to connect to the Pi. Open the VNC viewer you downloaded earlier and enter raspberrypi.local:1 for the VNC Server. Leave the Encryption at the default setting and click Connect. Ignore the warning and enter the password you created earlier ("raspberr").
  4. The VNC window itself should appear. You're all set!