HOWTO: Configure Your Raspberry Pi With VNC Without Ever Connecting It To A Keyboard & Monitor

/howto-configure-raspberry-pi-with-vnc-without-ever-connecting-keyboard-monitor 2012-07-20T16:03:14+01:00

So your Raspberry Pi has just arrived in the post and you're anxious to get playing, but alas, you don't have a spare keyboard, mouse and monitor at hand or you can't use any of the monitors and TVs available to you. This post details how you can use a single computer and network cable to get your Raspberry Pi up and running with VNC without ever having to connect a keyboard, mouse or monitor to it.

  1. Download the latest Raspberry Pi SD Card image. I'm using directly from Raspberry Pi's download page.
  2. Install the OS onto the SD Card as per the RPi Easy SD Card Setup instructions.

    My Dell E6410 laptop has an SD Card slot and I run Ubuntu on it, so this was a simple case of running:

    $ sudo dd bs=1M if=./2012-07-15-wheezy-raspbian.img of=/dev/mmcblk0
  3. (Optional) Manually resize the SD card to consume the full space using parted(1M)

    $ sudo parted /dev/mmcblk0
  4. The actions you take in this step really depend on how much control you have over your network.
    1. You have no DHCP server on your network and thus need to assign a static IP address:

      1. Mount your newly "installed" SD card
      2. Modify the etc/network/interfaces file on your SD card and configure the IP address you desire, eg
        iface eth0 inet static

        Full network configuration instructions can be found on the Debian wiki.

      3. Umount your SD card and insert it into your RPi
    2. You have no control of your network and thus have to rely on the DHCP assigned IP address:

      1. Mount your newly "installed" SD card
      2. Modify the etc/dhcp/dhclient-enter-hooks.d/debug file on the SD card and change RUN="no" on line 10 to RUN="yes" and save the file.
      3. Insert your newly "installed" SD card into your RPi.
      4. Connect the network cable and power and boot the RPi. Leave it for a few minutes to boot completely and obtain an IP address.
      5. Power off the RPi
      6. Remove the SD card, insert and mount it on your PC
      7. Obtain the IP address assigned on the last boot by viewing the contents of the tmp/dhclient-script.debug file. The contents will look similar to the following:
        Sun Jul 15 19:42:26 UTC 2012: entering /sbin, dumping variables.
        new_ip_address=''		⬅ HERE'S YOUR IP ADDRESS

        Take note of the IP address. Thanks to the fact that DHCP will always try and reuse IP addresses requested by a client in a short period of time, we can be pretty confident we'll get the same IP address when we next boot the RPi (provided we don't leave it too long).

      8. umount the SD card, transfer back to the RPi
    3. You have full control of your DHCP server:

      You don't need me to tell you what to do here :-)

  5. Now you know the IP address of your RPi simply power it up and login using the default login details.
  6. Install VNC Server

    $ sudo apt-get install tightvncserver
  7. Start VNC Server

    $ vncserver :1 -geometry 1024x600 -depth 16 -pixelformat rgb565
  8. Connect to the VNC server running on your RPi on port 5901 using your remote desktop client of choice. I use Ubuntu's Remote Desktop.
  9. Enjoy

For those who like screenshots, here's me connecting to my RPi after following the above...

RPi over VNC
Raspbian over VNC

At this point you may want to consider adding your own user and either remove the default user or at least change the default password. I'll leave that to you to decide.

Update: Spammers have spoiled the party folks. This post has suddenly become very popular with spammers so I've disabled comments on it. If you wish to comment, please feel free to comment via Twitter (@lildude) or via Google+

Copyright © 2005 - 2021 Colin Seymour All rights reserved. Privacy Policy.
Check out the feed if you do the RSS/Atom thing.