[Bassetlug mailing] Setting up SSH and VNC on Raspberry Pi

Danny Roberts dannyroberts.personal at googlemail.com
Thu Jun 7 09:19:22 UTC 2012


As promised the complete instructions for setting up SSH then VNC on your
RasPi so no more need for a monitor or other peripherals (Props to those
who intially provided all these pieces):

Log into your Raspberry Pi

 > sudo ssh-keygen

just enter at all prompts. you do not need a passphrase etc.

 > sudo service ssh start
 > sudo update-rc.d ssh defaults
 > sudo reboot

The last two lines will make the RasPi load the ssh daemon whenever it
reboots and then reboot to make sure it is tested. You can check if it has
reloaded after the boot with

 > sudo service ssh status

At this point there should be no reason to be running a monitor as you can
just SSH in which is done in linux like so:

ssh username at hostname

e.g. ssh pi at 192.168.1.30

To install and run the vnc server:

 > sudo apt-get install tightvncserver
 > tightvncserver

The first time you will get asked for passwords.

the server is running as the pi user. If you precede by sudo then the
server runs as the root user.

Use a VNC client with the address of the RasPi, note the ':1' on the end:
192.168.0.60:1

To set the VNC server to run at boot without any manul intervention follow
these steps:

> cd /etc/init.d
> sudo vi tightvncserver

Then populate the file you just created with this script (Minus the
"brackets"):

script start ----------->
#! /bin/sh
# /etc/init.d/tightvncserver
#

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    su pi -c '/usr/bin/vncserver'
    echo "Starting VNC server "
    ;;
  stop)
    pkill vncserver
    echo "VNC Server has been stopped (didn't double check though)"
    ;;
  *)
    echo "Usage: /etc/init.d/blah {start|stop}"
    exit 1
    ;;
esac

exit 0
<---------- script end

> sudo chmod +x tightvncserver
> sudo update-rc.d tightvncserver defaults
> reboot

At this point when the RasPi has rebooted you should be able to VNC or SSH
in as required.

-- 
Kind Regards
Danny R

Website: http://danny-roberts.info/


More information about the Bassetlug mailing list