Setup Your Raspberry Pi to Allow Remote Access

Setup Your Raspberry Pi to Allow Remote Access
If you would like to use your Raspberry Pi without it’s own screen you can do so by setting up a
Virtual Network Computing (VNC) server on the Pi and then connecting to the Pi over a network
cable from your laptop. This way you will be able to see the screen of your Pi on the laptop as if it
was a normal windows application.
These instructions assume you have a linux based OS (such as Raspian) already loaded and running
properly on your Pi SD card.
To begin we need to setup the VNNC server on your Pi.
On your Raspberry Pi:
When the linux OS is loaded, open a terminal windows.


At the prompt type: “sudo apt get install tightvncserver”
o If you are asked for a password, use “tightvncserver”
When the install is complete, the server can be started by typing the following at the
terminal prompt type: “vncserver :0 -geometry 1920x1080 -depth 24”
The “:0” means that vncserver will start a session on display 0. The “-geometry 1920x1080”
is the resolution to display at. This is a really long command to remember and type though,
so next we will automate the start-up of the vnc server.
To automate starting the server on the Pi so that it is easier for us to start it:



Create a file called vnc.sh by typing the following at the terminal prompt: “touch vnc.sh”
To add some content to the file, open it with the nano file editor by typing the following at
the terminal prompt: “nano vnc.sh”
Type the following two lines into the editor:
#! /bin/sh
vncserver :0 -geometry 1920x1080 –depth 24 -dpi96
Once finished press Ctrl + o to save the file, then Ctrl + x to exit the nano editor.


The file is still just a file at this point we need to make it executable. At the terminal prompt
type: “chmod +x vnc.sh”
If we wanted to run this file we could then just type “./vnc.sh” at the terminal prompt,
which is much easier!
This is much easier, but when we connect via a laptop we need the server to already be started, and
without a screen or keyboard to type commands at. To solve this we will set the OS to start the vnc
server whenever the OS boots up.
To set the vnc server to run at boot:

Change your user status to super-user from normal user by typing the following at the
terminal prompt: “sudo su”




Then, still in the terminal, navigate to the directory etc/init.d/ by using the change directory
(cd) command at the terminal prompt: “cd /etc/init.d/”
We need to create a new file to tell the OS to run the vnc server at boot, we can do this in
the same way we created the vnc.sh file, but this one will be called vncboot. Use the
following at the terminal prompt: “touch vncboot”
Then: “nano vncboot”
In the nano editor type:
#! /bin/sh
# /etc/init.d/vncboot
USER=root
HOME=/root
export USER HOME
case "$1" in
start)
echo "Starting VNC Server"
#Insert your favoured settings for a VNC session
/usr/bin/vncserver :0 -geometry 1280x800 -depth 16 -pixelformat rgb565
;;
stop)
echo "Stopping VNC Server"
/usr/bin/vncserver -kill :0
;;
*)
echo "Usage: /etc/init.d/vncboot {start|stop}"
exit 1
;;
esac
exit 0



Save the file and exit nano (Ctrl + o then Ctrl + x)
Change the mode of the file using: “chmod 755 vncboot”
Then enable dependency-based boot sequencing using: “update –rc.d /etc/init.d/vncboot
defaults”
o
o

If this completes OK you will see the: “Using dependency based sequencing”
If you see “update-rc.d: error: unable to read /etc/init.d//etc/init.d/vncserver” try
the following command “update-rc.d vncboot defaults”
Reboot the Pi
On your windows laptop:

While the Pi is connected to your Windows laptop open the command prompt (Windows
menu > command prompt) and run the command
“arp –a”
or
“net view /all”
To find the IP address of the Pi.

Then install and configure tightvncserver on your windows laptop using the instructions
here: http://www.raspberrypi.org/documentation/remote-access/vnc/windows.md