A friend of mine recently bought a Raspberry Pi, but hasn’t done anything with it yet. Last night, he was reading the articles I posted last week about working with the Raspberry Pi and called me for a quick chat. During our call, he was asking if there was anything he could use on the Raspberry Pi that made it behave more like Windows. He said he hasn’t done anything with the Raspberry Pi because he doesn’t know all of the commands and hates how everything is done in a shell. As you can probably guess, my friend isn’t much of a techy and has absolutely no experience working with Linux. I think this is the real reason he hasn’t done anything with his RPi. So, I introduced him to LXDE which is accessible by typing “startx” at the shell and pressing Enter. This was exactly what he was looking for and he now has a whole new excitement about working with the Raspberry Pi. By the end of our conversation, he said,
“You know, it would really be cool if I could run this from my Windows computer and not have to connect a mouse, keyboard, and monitor to the RPi every time I want to play with it. Even though I didn’t like the shell, I did like the fact that I could plug up my RPi, stick it in the corner, and connect to it remotely using SSH.”
I think he probably pissed in his pants when I told him that he could do exactly that with LXDE. I told him that he could run VNC on the RPi which would allow him to access the LXDE desktop remotely. But, just like everything else, he had no clue what VNC was. So, I spent the night exchanging emails with him explaining to him how to install VNC and connect to his RPi remotely. Since I already created the screenshots for him, I decided I would go ahead and use those same screenshots for anyone else interested in connecting to their Raspberry Pi remotely. Let’s begin.
Before we get too far, this article is intended for those of you that want to connect to your RPi remotely from a Windows computer. Even though the same software is available for other operating systems, I’m going to focus on Windows as that’s what my friend was using. You will also need to make sure that your RPi is connected to the internet as the commands we are going to run will need to go out to the web and fetch a few pieces of software to be installed.
To get started, you will need to log into your RPi either directly from the attached mouse, keyboard, and monitor or by connecting remotely via SSH. Once you have connected and logged into your RPi, you will first need to run an update just to make sure that everything is up to date.
sudo apt-get update
Next, you will want to issue the install command for “tightvncserver” like so
sudo apt-get install tightvncserver
As soon as you run the command, you will be asked to confirm that you do in fact want to install tightvncserver. So, you will need to type “Y” and press enter. Give your RPi a few seconds (depends on your internet connection speed) to fetch and install the VNC server.
Once it’s installed, you should be back to a prompt at which time you are ready to start up the VNC server. To do that, you will need to run the following command.
This will launch the VNC server as a background process. When the server starts, you will be asked to enter and confirm a password that you will use when connecting to the RPi remotely. The password only accepts up to 8 characters. You will also be asked if you want to create a readonly password as well. Unless you have some specific reason to do otherwise, type “n” and press enter.
That’s it. You now have your VNC server running. However, every time you restart your RPi, you will need to restart your VNC server by again issuing the “vncserver :1” command as before. In a future article, I will show you how to setup your VNC server to startup every time you reboot your RPI. But, for now, I am going to move on to showing you how to connect to your VNC server from Windows.
For that, you will need to download and install a VNC client. I personally like the RealVNC Viewer which you can download for free from http://www.realvnc.com/download/viewer/. You can also download the VNC client for other operating systems such as Mac, Linux, Solaris, HP-UX, and AIX on that same page. As mentioned earlier, if you download the client for one of the other operating systems, you will need to look elsewhere for information on installing and using the software. If you’re using Windows, the easiest thing to do is to download the “exe” version for your system. Since I’m running Windows 64 bit, I chose to download the 5.0.5 64-bit exe.
After you have downloaded the executable, go ahead and run it. The first thing you will see is a dialog asking for the name or IP address of your RPi. If you connected to your RPi earlier using SSH, you will already know the IP address of your RPi. If you do not know the IP address of your RPi, you can get it by typing “ipconfig” in a shell. This will display all of the available adapters on your RPi.
If you are using a wireless dongle on your RPi, you will need to look for the “inet addr” next to “wlan0“. If you are using a wired ethernet cable, you will need to look for the “inet addr” next to “eth0“. Since I’m using a wireless dongle, my IP address was listed next to the “wlan0” as indicated above in the red box. Once you have the IP address of your RPi, enter it into the “VNC Server” field of the VNC client. You will also need to add “:1” after the IP address just like you did when you started the VNC server. Then press the “Connect” button.
On the next screen, you will be asked to enter the password you created when installing the VNC server. Go ahead and enter that same password here and click the “OK” button.
If you followed this article correctly, you should now see your LXDE desktop in the VNC client.