Update 29th Dec, 2016: If you’re using the latest PIXEL Image, please make sure you enable the SSH Server by placing a a file named as ssh in the boot directory before trying any of the following methods. The SSH Server on boot has been disabled in the latest Raspbian image as a security measure. Read more about it here: https://www.raspberrypi.org/blog/a-security-update-for-raspbian-pixel/
Before you go neck-deep into this post, please check if this post is applicable for you:
What you want to do:
- Access Raspberry Pi’s desktop on Laptop/PC screen
What you have:
- Raspberry Pi A+/B/B+/Pi 2 (If you’ve a Pi Zero, please try and let us know if this works on a Zero. Not tested with a Pi 3 either) running the latest Raspbian Wheezy (I’ve not yet tried it with recently released Raspbian Jessie based off Debian 8. If you’ve been successful with this latest release, please post in the comment and I’ll update it here. Thanks.)
- Laptop (Windows 7 or XP with Internet connection, required to download one setup file)
- A working SSH connection with Raspberry Pi (direct access, explained below)
What you don’t have (and not required):
- Display Device for the Raspberry Pi (HDMI enabled display unit / Old TV)
- Internet connection for the Raspberry Pi (LAN or WiFi)
Extra Stuff you need:
- Standard Network Cable (Cat 5, Standard or Crossover)
- PutTTY Software (will be used to SSH into the Pi)
- SD Card Writer
There are hundreds of tutorials sprawling across the web that show you how to remote access your Raspberry Pi’s desktop from your laptop/PC. This will come handy if you don’t have (or don’t want) a display unit to see your Pi or want to use your Laptop/PC’s screen and keyboard/mouse itself. This mode of accessing the terminal and/or desktop of the Raspberry Pi without connecting it to any display unit (and not connecting any keyboard/mouse to the Pi) is usually termed as Headless mode.
In most of the remote desktop tutorials, you’d need to initially install TightVNC Server (software that streams the Desktop’s GUI to any VNC Client) on the Raspberry Pi and then install any VNC viewer on the Laptop/PC. Now, installing TightVNC server on the Raspberry Pi requires it to be connected to the internet. And here’s my problem: I don’t have a Router or Internet cable in my home. I essentially use a 3G dongle for all my internet needs.
We even tried installing XRDP onto Raspberry Pi (by copying the tar and running it on the Pi) but this failed as it tried downloading the missing dependencies.
We tried couple of methods to share our Laptop’s internet connection with the Raspberry Pi but they failed. Desperate still to access my Raspberry Pi’s desktop, we stumbled upon this setup which finally worked.
Before we proceed with remotely accessing the Raspberry Pi’s desktop, we first need to be able to SSH into it (access it’s shell, akin to command prompt in windows OS). The procedure for SSHing into the Raspberry Pi without the need of any Display Device for Raspberry Pi is explained below.
Direct SSH into Raspberry Pi in Headless Mode
In this tutorial, we’ll quickly setup our Raspberry Pi connected locally to our PC/Laptop using a standard Cat 5 Ethernet cable (crossover not required).
Edit: 1st Jan, 2015:
Edit: 11 September, 2015: Can someone please confirm if this works on Windows 10? Thanks.
I compiled a quick video illustrating the following steps so that you can configure it more easily.
Please follow the below steps to have a working SSH connection:
- Install and burn the latest Raspbian Wheezy OS onto the SD card for the Raspberry Pi
- While the Raspberry Pi is switched off, connect one side of the Ethernet cable to Raspberry Pi and other side to the RJ45 jack of the PC/Laptop
- Open LAN properties and make sure that IPV4 properties are set to Obtain IP address automatically as shown below:
- We now need to determine the IP of our PC/Laptop when it’s connected to the Raspberry Pi
- Now power on the Raspberry Pi while making sure that the network cable is connected on both ends
- Wait for a min or two. You’ll notice that the PC/Laptop will scan and then show a small warning indicating the presence of an unidentified network
- Now, open command prompt and type ipconfig. Note the IP of the Ethernet Adapter Local Area Connection as shown below:
In our example, its 169.254.39.68
- Now, power off the Raspberry Pi and take out the SD Card. Plug in the SD card into a card reader and open it. You should see a couple of files
- Open the cmdline.txt file and append this to the end of it:
Please change the IP accordingly and assign a unique value (while making sure you don’t go beyond the subnet mask). Preferably, change only the last parameter
For example, if your LAN’s ip is 169.254.0.1, we recommend using 169.254.0.3 as the IP for Raspberry Pi in cmdline.txt
- Save the cmdline.txt file without making any other changes
- Plug this back into the Raspberry Pi and with the Ethernet cables connected, power on the Raspberry Pi
- Wait a couple of minutes while the Raspberry Pi tries to establish a local network connection with our PC/Laptop
- Once you see the network warning message as shown above, ping the Raspberry Pi to see if it’s live on the network as follows
- Open CMD prompt
- Type ping ipaddress_of_raspberry-pi
Ex: ping 169.254.39.71
If all went good, you should see the Pi responding back to the ping requests as shown below:
- Now its time to SSH into the R Pi. Open PuTTY client and type in the IP address of the Raspberry Pi (169.254.39.71) and hit Open
The password should be raspberry
Voila, you’re now SSHed into the Ras Pi. It’s all yours now
Now, moving on to access the Raspberry Pi’s desktop, we first need to install Xming X Server for windows from this link:
Make sure you install the SSH components also when prompted to do so.
Once that gets successfully installed, simply click the Xming icon and make sure it’s running in the background
Once inside, simply type in midori and this should bring the Midori browser as a window.
Note (Edited: 5 Feb, 2015): As of the latest Raspbian version (December 2014 release), Midori browser has been replaced by Epiphany Browser. You will get an error if you hit in midori. I’d recommend you hit in this command leafpad that will bring up the text editor instead.
We’ll now hit in lxsession or startlxde and that should pop up the desktop of the Raspberry Pi:
In order to close this, go back to the PuTTY terminal and kill this process using Ctrl + C
Note: This for some reason is still not showing the lower part of the Desktop including Start menu and taskbar.
EDIT: The LXPanel that was missing was because of a messy config file in one of the image files. I’m able to see the LXPanel also on a clean image.