Getting Started with Python for the Internet of Things
上QQ阅读APP看书,第一时间看更新

How to do it...

Linux and OS X have built-in support for X11 forwarding, but if you are using Windows, you will need to install and run the X Windows server on your computer.

Download and run xming from the Xming site (http://sourceforge.net/projects/xming/).

Install xming, following the installation steps, including the installation of PuTTY if you don't have it already. You can also download PuTTY separately from http://www.putty.org/.

Next, we need to ensure that the SSH program we use has X11 enabled when we connect.

For Windows, we shall use PuTTY to connect to Raspberry Pi.

In the PuTTY Configuration dialog box, navigate to Connection | SSH | X11 and tick the checkbox for Enable X11 forwarding. If you leave the X display location option blank, it will assume the default Server 0:0 as follows (you can confirm the server number by moving your mouse over the Xming icon in the system tray when it is running):

Enabling X11 forwarding within the PuTTY configuration

Enter the IP address of Raspberry Pi in the Session settings (you may also find that you can use Raspberry Pi's hostname here instead; the default hostname is raspberrypi).

Save the setting using a suitable name, RaspberryPi, and click on Open to connect to your Raspberry Pi.

You are likely to see a warning message pop up stating you haven't connected to the computer before (this allows you to check whether you have everything right before continuing):

Opening an SSH connection to Raspberry Pi using PuTTY

For OS X or Linux, click on Terminal to open a connection to Raspberry Pi.

To connect with the default pi username, with an IP address of 192.168.1.69, use the following command; the -X option enables X11 forwarding:

ssh -X pi@192.168.1.69  

All being well, you should be greeted with a prompt for your password (remember the default value for the pi user is raspberry).

Ensure that you have Xming running by starting the Xming program from your computer's Start menu. Then, in the Terminal window, type a program that normally runs within Raspberry Pi desktop, such as leafpad or scratch. Wait a little while and the program should appear on your computer's desktop (if you get an error, you have probably forgotten to start Xming, so run it and try again).