Installing Raspbian on the Raspberry Pi & using SSH and VNC to remotely connect to the Raspberry Pi

UPDATED: July 18th 2013

This blog entry will describe:

  1. The installation of the Raspbian Wheezy Linux Distribution on an SD card.
  2. Powering up the Raspberry Pi (RPi) board and connecting it to the network
  3. Remotely Accessing the RPi board via SSH
  4. Initial Configuration of the Rasbpian OS/ RPi board
  5. Remotely Accessing the RPi’s graphical desktop environment (LXDE) via VNC

For starters you’ll need a microUSB terminated AC adapter, an Ethernet cable & an SD card.  I highly recommend that you use a 4GB SD card as a minimum.  Also this tutorial assumes that you are running a Debian or Ubuntu Based Linux operating system on your PC. I myself run  Crunchbang Linux 11, which is based on Debian Wheezy 7.  If you are running a fresh install of Debian Wheezy please setup the sudo utility appropriately.

Installing Raspbian on your SD Card

  • Plug in the SD card into the PC then run the following command in a terminal window: “sudo fdisk -l“.  This will list all of the available drives available on your PC as shown in Figure 1.
Figure 1. Display all hard/flash drives attached to the PC with the 'fdisk' command

Figure 1. Display all hard/flash drives attached to the PC with the ‘fdisk’ command

  • From the output in Figure 1 you can see that the operating system detects two drives, “/dev/sda” is a 64.0GB SSD drive and the “/dev/sdb/” is our 8.0GB SD card.
  • The next step is to download the latest Raspbian Wheezy Linux distribution image from this page. Take note of SHA-1 hash string and the username (pi) and password (raspberry) listed on the page.
  • Once downloaded, in a terminal window, navigate to the folder containing the compressed Raspbian image with “cd“.
  •  Type the following command: “sha1sum“. Where the ‘x’s should represent the compressed image version. After a few seconds, a long string will be printed in the console window. Compare this  string with the one on the Raspbian download page. If the Raspbian image  is complete and not not corrupted, then both strings (hash codes) should be identical.
  • Now that you verified the file integrity of the compressed Raspbian image, uncompress it using the following command:  “unzip“. You should end up with another file called “20xx-xx-xx-wheezy-raspbian.img”.
  • Copy the Raspbian image to the SD card using the following command: “sudo dd bs=1M if=20xx-xx-xx-wheezy-raspbian.img of=/dev/sdb“. Make sure that you specify the correct device found using the fdisk command.   This command will take a few minutes to complete.
  • Once the “dd” command completes, type into the same terminal “sudo sync” to ensure the write cache is flushed properly and that you can safely remove the SD card. Remove your SD card from the card reader and plug it into your RPi.

Putting the RPi with Raspbian OS onto the network

  • We will connect to the RPi over the network. This way we can access both our Linux PC and the RPi through a single monitor….no need to have multiple monitors and HDMI cables. This can be done in two ways:
    • Connect the RPi directly  to the network via an Ethernet Switch
      • Power your RPi & connect it to your network (via an Ethernet port on an accessible switch connected to your home network) using the Ethernet cable.  You should see the LEDs start to come up implying that the Raspbian image has been successfully started. Once the green “LNK” LED and the “10M” orange LED light up on the RPi board, we can assume that the Raspbian image booted and an IP address has been assigned to the RPi. To figure out the IP address assigned to the RPI by the DHCP server running on our router, we can use the IP Scanner tool nmap.  Install nmap on your Linux PC :”sudo apt-get install nmap“.  Then type “sudo nmap -sP“. This command lists all IP addresses that are up on your local network (typically a network). Find the one that lists “Raspberry Pi Foundation” next to its MAC address (Figure 6). That is the IP address of the RPi. Keep record of it since we will need it to SSH into our RPi.
  • Share your PC’s Internet Connection with the RPi
    • If there is  an unused Ethernet port on the Linux PC, it can be used to allow the RPi to share the network/internet connection that the Linux PC is connected to through another WiFi /Ethernet port.
    •   To create this network bridge, open the Network Manager application. This can be done from the task bar and should open the “Edit Connections” dialog shown in Figure 2.
Figure 2 Edit Connections

Figure 2 Edit Connections

    • Select “Wired Connection 1″ and click on the “Edit” button. If you do not have a wired connection profile,  click the “Add” button.
Figure 3

Figure 3

    • Change the “Connection name” field to “Raspberry Pi Bridge”. In the “Device MAC address” drop down list, select the MAC address of the unused Ethernet port (eth0 in my case). Then go to the IPv4 settings tab and in the “Method” drop down list, select “Shared to other computers”.
Figure 4.

Figure 4.

    • Under the IPv6 settings tab and in the “Method” drop down list, select “Ignore”. and then press save.
    • Now Power up the RPi & connect it via Ethernet cable to the unused Ethernet port on your PC. Once the green “LNK” LED and the “10M” orange LED light up on the RPi board,  the Raspbian image has booted and an IP address has been assigned to the RPi.
Figure 5.

Figure 5.

    • Now go back to the terminal and type “ifconfig -a“.
Figure 6

Figure 6

    • Note how the IP address on the eth0 interface is  now This implies that the Linux PC is  basically  acting as a router between the network ( really only a point to point network ) on which the RPi  and eth0 are attached, and the network, which is attached to the internet & PC  via the wlan0 interface. Also note that the mask for the network is . This means that the IP address of the RPi is somewhere between &  To find the exact address we can use nmap  “sudo nmap -sP″. In my case, nmap reported that the my RPi has an IP address of (Figure 6). If nmap is not installed, you can easily install it with “sudo apt-get install nmap“.

Accessing the Raspberry Pi board remotely via SSH

  • Now that we know the IP address of the RPi board, we we can login remotely via SSH. SSH is an encrypted version of telnet (with a few additional goodies) that can give us command line access to the  RPi  over the network. To login into the Raspberry Pi over SSH we need to type in our terminal: “ssh -l pi” (or ssh pi@ Basically we’re typing the name of the command “ssh” followed by the IP address of the RPi, followed by the username. Remember the default username for the Raspbian Distribution is “pi” and the password is “raspberry”.
  •   Choose yes if  asked if this is a safe connection ( first time to ssh into the RPi). If all goes well, our terminal window is logged into the RPi. Any commands that we type into that window from now on will affect the Raspberry Pi and not the Linux PC.
Figure 7. Logging into the RPi via SSH and typing "sudo raspi-config"

Figure 7. Logging into the RPi via SSH and typing “sudo raspi-config”


Configuring your Raspberry Pi over SSH

  • The next step is to type “sudo raspi-config“. (see notice in Figure 7) Once you do this, the raspi-config tool will run (figure 8).
Figure 8. ncurses based raspi-config tool

Figure 8. Ncurses based raspi-config tool

  • From the raspi-config menu, first select “8 Advanced Options” -> “A5 Update” & hit enter. This will update the raspi-config tool to the latest version.
  • The Raspbian image is designed to expand into 2GB space on your SD card. This means that if you are using a larger SD Card, say 4GB or 8GB, the additional space is not part of the root file system partition.  To use all the space on your SD card  select “1 Expand Filesystem” and hit enter. This will expand the root file system partition to fill the entire SD card. The actual partition expansion will happen on reboot.
  • The other major option is “8 Advanced Options” -> “A3 Memory split”. Hit “Enter” and then choose an appropriate memory split ratio. I recommend using 64MB for the  GPU, but you can change this depending on what you are doing.
  • For the other options, I highly recommend that you explore them…..I don’t recommend overclocking the RPi ( “7 Overclock” option) beyond 800MHz and I keep the default for the “8 Advanced Options” -> “A4 SSH” (run SSH server on start up) . For “3 Enable Boot to Desktop”  I always choose to boot into the command line first.
  • When you’re done, use the right/left arrow keys (or tab key) to select <Finish>. This will cause the RPi to reboot with all the requested changes. This reboot might take an additional  minute or two if you selected to expand the root file system partition. Note that when you reboot, you lose your SSH connection and your console window will now be associated with your Linux PC once more.
  • When the RPi reboots, SSH into it again via “ssh -l pi” as before.
  • Once at the RPi prompt shown (Figure 7), type “sudo apt-get update” followed by “sudo apt-get upgrade” or alternatively we can do both at the same time “ sudo apt-get update && sudo apt-get upgrade“. The first command consults the /etc/apt/sources.list and updates the database of available packages. The second command checks updates for all installed packages and then prompts to download and install them. When it does this accept  the updates (type Y) and hit enter. When the second command completes ,you will have the most up-to-date Raspbian Linux OS available for the RPi.

Remote login into the Raspberry Pi Using VNC

SSH is great if you want to remotely access the RPi from the command line. The Raspbian OS also comes with a Desktop GUI environment called LXDE. If can access the LXDE desktop over HDMI by typing “startx” in the command line window. This will not work over SSH. Luckily we can still remotely access the LXDE Desktop from the Linux PC, using the VNC protocol.

  • First we need to install the VNC server software on the  the RPi. To do this, SSH into the Raspberry Pi and type “sudo apt-get install tightvncserver“. This will install the VNC server software on the RPi. Then type “tightvncserver” to configure the VNC server for the first time. You will then be asked to enter a password (8 characters only)  & confirm it. I used “raspberr”. You will then be prompted to enter an optional “view only password”. This is not needed and you can choose to not set one by saying no. the next step is to type the following into the RPi SSH session  to start the VNC server: “vncserver :1 -geometry 1280×720 -depth 24“. This starts a VNC server on display number 1 with a resolution of 1280 by 720 and a color depth of 24. At this point the VNC server should be running on the Raspberry Pi.
  • Now open another console window on your Linux PC and install a VNC viewer (client) on the Linux PC with the command: “sudo apt-get install xtightvncviewer “. Then in the same console window (Linux PC)  type “xtightvncviewer &“. The ampersand allows us the run the application in the background.
Figure 9. Start the VNC server on the RPi and the VNC viewer on the Linux PC

Figure 9. Start the VNC server on the RPi and the VNC viewer on the Linux PC

  • This will open the VNC viewer on our Linux PC (a small messagebox…see Figure 9). Type in the VNC server address that you want to connect to i.e. the RPi IP address & display number “″.  You will then be prompted to enter your VNC password. Type that in and press enter. You should see the window shown in Figure 10. You now have full control over your Raspberry Pi via both the command line with SSH  and the desktop environment over VNC.
Figure 10. Accessing Raspbian's LXDE Graphical Desktop over VNC on your Linux PC.

Figure 10. Accessing Raspbian’s LXDE Graphical Desktop over VNC on your Linux PC.


Another cool article on Setting up your Raspberry Pi can be found here: Raspberry Pi-ing, MacGyver Style



This entry was posted in Raspberry Pi. Bookmark the permalink.

30 Responses to Installing Raspbian on the Raspberry Pi & using SSH and VNC to remotely connect to the Raspberry Pi

  1. Leopoldo says:

    Thank you so much

  2. PCees4u says:

    It works fantastic! Excellent blog!

  3. Perfect! Seems like such a simple thing but having never set this stuff up via SSH this blog helped me out immensely. The whole process was so clear, concise, and easy to follow, that for once I was not the bottleneck in the equation.

    Thank you for your work!

  4. Cedric Quentin says:

    Thanks so much mate !! It worked straight away !!

  5. Pingback: Basic setup RaspberryPi | RSBox

  6. Peter says:

    Thank you very much! So well explained! :)

  7. Ranjan Batra says:

    Hey Man!!!

    This is really awesome!

    Got it running in a matter of minutes and understood the concepts as well!

    Well done!!!

    Do you have something like this for pandaboard also?



    • halherta says:

      The RaspberryPi runs the Raspbian OS which is basically Debian optimized for the RPi Sp if you install either Debian or Ubuntu (based on Debian) on the pandaboard, the process should be similar. You can build a Debian demo image for the Pandaboard using instructions here .These instructions will enable you to install debian for the Pandaboard in minutes.

      For the absolute latest kernel, bootloader and rootfs I recommend these instructions . This approach is longer as it provides you instructions to build each component separately (kernel, rootfs, bootloader e.t.c) but it is very informative and ensures that you get the most bleeding edge kernel available.

      Both tutorials help you create a minimal Debian image without the lxde desktop environment to install it, once you ssh onto Debian on the pandaboard type “sudo apt-get install lxde-minimal”.

      • Ranjan Batra says:

        Hi Halherta!

        Thanks for this!

        I have to say that you are really awesome!

        I could do debugging on Pandaboard easily following your explaination for Raspberry Pi! I could easily understand the concept behind it and corelate it for Pandaboard.
        I am using eclipse for parallel at the moment.

        Also, do you have any idea about the real-time patches for pandaboard?



  8. Pingback: .NET i jiné ... : Odkazy z prohlížeče – 26.7. 2013

  9. lorentz says:

    thanks for the info on “sudo nmap -sP″ .before knowing this i had to set a static ip for headless connection. i have added that command to my blog

  10. JASON says:

    thank u so much, I come form china, with the help of google translate, I got a lot form this blog

  11. Newton says:

    This is a great an really helpful article. Thanks so much for the time you put into documenting all of this. I got my RPi up and running and connected to it using VNC thanks to you and this great article.

  12. AC says:

    This is one of the most straight-forward, bug-free articles I’ve happened upon! Works perfectly. Thank you so much for the time and effort!

  13. Nikhil says:

    Hi Halherta,
    Thank you so much. I was able to connect to my pi by following the instructions given.
    But I guess I am not able to connect to the internet from my Pi. I have been trying several things but not really working out. I tried pinging to my ubuntu machine ip address (which I have connected to the Pi) from Pi and that works but nothing else..

    I am not able to do sudo apt-get update or any commands which require connecting to net. Its frustrating that I can connect to pi but not connect to net from Pi..

    Could you tell me how can I get around this..?

    • halherta says:

      Nikhil, This usually happens if your local network is behind a firewall or a proxy server…..this is very likely a problem with your network setup…….If you are using the RPi at School/Work thats is definitely the problem and you’ll have to speak with your network administrator. If at home, check your router settings…

  14. Recluster says:

    Thank you very much, very helpfull tips (and time saving ;))

  15. DANNY says:

    Thanks a lot., u have done a gr8 job.,

  16. Pingback: Thermometer (using Arduino and RaspberryPi) | renatoppl :: blog

  17. Orkun_K says:

    Hi halherta your RPi tips are very helpful and very thanks to you.

  18. rj says:

    i keep receiving error for
    vncserver :1 -geometry 1280×720 -depth 24
    vncserver: geometry 1280×720 is invalid
    and i never have request for password after window

    • halherta says:

      rj, make sure the ‘x’ in 1280×720 is lowercase…also type it into the terminal window….don’t copy paste

  19. Pingback: Raspberry Pi Model B+ - Rio Pilas Rio Pilas

  20. Jetson Davis says:


    I am trying to set up my RPi B+ via SSH as above, but I get a ‘connection refused’ back from the Pi. I assume this means SSH is not enabled? I don’t even have a USB keyboard (laptop only). Is there a way to enable SSH by altering the SD card?


    • halherta says:

      With a new install of Raspbian, the SSH server should be enabled by default. If it was disabled, you’ll need an alternate way of getting access to the commandline. The easiest way is to plug a screen, keyboard & mouse to the RPi and re-enable the SSH server with rasp-config (or double check the RPi’s IP address). You could also access the commandline via the serial port on the IO pins. Or try a fresh install.

      Finally if this is happening on a fresh install…..double check the IP address of the RPi. If you’re trying to SSH into the wrong IP address It will obviously fail. You could use nmap on a Linux machine or an IP scanner on a windows machine on the same network to verify the IP address of the RPi.

      • Jetson Davis says:

        Thanks for the reply. Turns out I had plugged the ethernet from the RPI+ to my laptop. Plugged it into the router and everything works. I believe I need a crossover cable to plug into laptop.

  21. Gerd says:

    Thank you very much for this good description.

    I have never used Eclipse before and only occasionaly use Linux. But following your step by step instructions I could set up cross compiler, Eclipse and Debugger in less than half a day.
    What helped most was the check points in the text from time to time.



  22. Anurag Rai says:

    I don’t have a router, but i can create a hotspot with my cell-phone. Can i apply you method in such a case?

  23. Pingback: Instalando raspbian sin teclado ni monitor, mediante SSH | Indecisoft's Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>