I wanted to be able to communicate and play with my Raspberry Pi. Specifically, I needed it to be set up with the following:
For the monitor, I happen to have a few to play with. Unfortunately, they’re all VGA, and the Pi only outputs to composite and HDMI. Also, since I don’t have a spare wi-fi USB stick, I can only hook the Pi up to the network at the router – which is far from my desk.
So, I decided to look into a “headless” option – running the Pi without any peripherals, connected only to the router. I wanted to be able to control the Pi from not only a shell (SSH/Telnet) connection, but also via its GUI. Turns out, for a total Linux n00b, it wasn’t so hard to do – just a matter of researching and experimenting. Here’s what I did.
Get thee to an OS
To start, I got an SDHC card (8GB, but I think a 2GB one will suffice), which will hold the OS “image” (data and applications), and inserted it into a PC. As of August 12, 2012, the current OS of choice according to raspberrypi.org is Raspbian Wheezy. As per instructions, I downloaded the SD image, as well as Win32DiskImager (careful – the latter has a few false “Download” advert buttons). I then used DiskImager to install the image (Don’t just copy the image to the SD card – it won’t work!) I then tested that the OS booted up on the Pi by sliding the card into the Pi. This is required before you can do the headless connection, so it requires borrowing a keyboard and monitor that has HDMI or composite support.
My main monitor accepts composite (I don’t recommend this – so blurry!), so I attached that.
Get an SSH connection
First, I had to get SSH set up. SSH is like a command-line interface, like Telnet – think being able to type and run DOS-style commands, but on another computer.
I then booted up the Pi, and started raspi-config (this runs on first boot).
Unfortunately, I had an error where the SSH keys would not generate, with the message: “Invalid ssh key generation still running. Please wait and try again.” So, I exited raspi-config, and ran the following at the command line:
sudo rm /etc/ssh/ssh_host* sudo ssh-keygen -A
Then I re-ran raspi-config, then selected “ssh” again to restart the SSH service, and set a password. Success!
Connect to network
I was then able to disconnect the Pi from the monitor/keyboard, and connect it to the router. This router controls my local area network (LAN), so I should be able to connect to the Pi from another computer within the LAN. First, I had to find what IP address the router reported the Pi at. I found that the hostname of raspberrypi usually works. If not, try the following:
I consulted the manual of the router, which directed me to load http://192.168.1.1/ for my Linksys WRH54G in a browser (Your router may have a different address). The front page shows all connections, and I was able to easily find my Pi. In this case, it’s at IP address 184.108.40.206.
I then installed PuTTY, which is a pretty good, simple SSH client. I opened it and set Host Name (or IP address) to the IP address of the Pi, and clicked Open. I was immediately prompted to log in.
login as: pi pi@<IP address>'s password: <SSH password I set in raspi-config>.
If you get something like this screen, you’re doing it right.
Getting a window
The next thing was to be able to see the PI’s GUI on my desktop. I followed the instructions here to install TightVNC on the Pi. This involves using apt-get, an application that installs Linux apps from an online repository. It’s an extremely useful and quick way to install the most popular free software.
sudo apt-get update sudo apt-get install tightvncserver /usr/bin/tightvncserver
You’ll need to set a password as well.
On the desktop machine, I then installed a VNC client. Both TightVNC and Real VNC have good clients. I’ll show TightVNC connecting. I installed and started the client, and typed in the IP address. NOTE: You need to append “:1″ to connect on port 1 of the Pi.
And if you get a screen like this on your PC, then grab a party hat, because you’re done!