Tuesday, March 12, 2013

The Pi Series: 2. Remote Access

So you are one of those unlucky people without a keyboard and mouse to connect to the newly setup Raspberry Pi. Well, if its any consolation, you are not alone and the world is not going to end. The beauty of Linux is that there seems to be a workaround for everything. Anyways, lemme tell you how to remotely control the pi from a Linux machine (one with a regular keyboard and mouse attached to it) or from an Android tablet for that matter. In this edition, I will stick to humble desktop/laptop.

  1. Raspberry Pi running Raspbian
  2. A linux machine - running a Debian based distro (I had an Ubuntu machine).
  3. LAN (I connected the pi using Ethernet cable and the laptop via WiFi)
If you want to access to Desktop of Pi, you need to have these two packages installed.
  1. A VNC Server in Pi - I used x11vnc
  2. A VNC Viewer in Linux machine - I used gtkvncviewer
How to Remotely Access Terminal of Pi
Before we start, please note that the default user name and password for Pi is 'pi' and 'raspberry' respectively. Now the procedure:
  1. Find out the IP Address of your Router and go to its settings page. To find out the IP address of Router, enter the command route in terminal of your Linux machine. In the output, look for 'Gateway' and the IP number mentioned below it. That is the IP Address of your router. Now, go to your router's settings page by entering the IP address of the router in a browser.
  2. Connect Pi to LAN and find out the IP Address of Pi in your LAN. To find out the IP address of Pi, Look for DHCP/DHCP Client Table (probably under LAN Status) in Routers Settings page. If you cant find out the IP, Google with model number as the procedure varies from router to router.
  3. In your Linux machine, take terminal enter the following command:
    ssh pi@<IP_OF_PI>
    (if the IP address of Pi is, command should be 'ssh pi@')
  4. Some text will flash and it will ask if you want to proceed further. Enter "Yes" and proceed
  5. Then It should prompt for the password for the user 'pi'. The default password is "raspberry". Enter the password.
  6. Now you should see the command prompt of Pi. That means you have logged in to Pi remotely.

How to Remotely Access Desktop.
Now you have access to command prompt of Pi. Lets see how to get the GUI.
  1. Connect to Pi via SSH command mentioned above and once you get the command prompt, install x11vnc by entering following command:
    sudo apt-get install x11vnc
  2. In the terminal of your linux machine, install gtkvncviewer by entering the command:
    sudo apt-get install gtkvncviewer
  3. Once x11vnc is installed, run it by entering x11vnc in the command terminal of Pi

  4. It will ask to setup a password for VNC. Choose a password and press enter (This is a one time exercise)
  5. Once GTK VNC Viewer is installed in your linux machine, run the program my entering the command gtkvncviewer
  6. You should get a dialogue box (like the one given below) asking you to enter the address etc of remote machine.

  7. In 'Server(:port)', Enter the IP address of Pi and port as 5900 (i.e. following the above example,
  8. Give the username as 'pi'
  9. Give the password you setup in step 4 above and press enter.
  10. Another window will appear with the desktop of Pi. 

Now you can use the keybord and mouse of your laptop/desktop to control Pi. Thats it for now.
Next Issue: Accessing Pi from an Android Tablet