When I first received my Raspberry Pi, I didn't have a monitor available, so every time I wanted to work with it I would have to go through the trouble of hooking it up to the TV or borrowing the monitor I used for my main computer. That didn't always go over well with my dearest, who's not into decor that incorporates multiple cables strewn randomly into its design.
Now that I have set up Remote Desktop on my Pi, I can easily access it via a window on my iMac, which means more time tinkering and less time dealing with setup details. It also means I can put the Pi anywhere else in the house (or in the yard or greenhouse!) and still have easy access. And as a bonus, it also means I get fewer dirty looks from my dearest ("fewer" being the key word there ).
If you are new to the Raspberry Pi, it will likely still be easiest to do the initial setup using your TV and maybe a borrowed keyboard/mouse, but then after you'll never have to go through all of that trouble again!
The process is quite simple actually - you will need to install a bit of software onto your Raspberry Pi, and you'll need a bit of software on the PC you'll be using to access it. The RPi software can even be installed remotely from your PC, if you have already set up your RPi.
Let's break your RPi free from all those peripherals right now, in just 3 easy steps! The other 17 steps are difficult . I'm kidding! It's just 6 easy steps. 7 if you plan on taking over the world.
Please note that I've written this tutorial for the Raspbian operating system, but the exact same steps can likely be used for any of the other distributions available for the RPi.
1. Set Up Your Raspberry Pi
First things first: if you have not already done so you will need to do the initial setup for your Raspberry Pi. There's no getting around that step, but do not fear - it's also fairly easy and automated. There are many tutorials available for that, so I will leave you to the experts for this step.
2. Find the IP Address of your RPi
To connect to your RPi, you will need to know its special phone number, known as the IP Address. Every device connected to your network will have their own special IP Address.
To find the IP Address for your RPi, use ifconfig from a command line on your RPi. Type the following at the command line and press the 'enter' key:
ifconfig
If you have already disconnected your keyboard and monitor from your RPi, you can still find its IP Address by asking your router for that information. On an Apple network, for example, Airport Utility can be used. I've attached an image of what this looks like.
For other routers, you can often connect to the admin panel of the router via a browser to find out this information.
Note that IP addresses can change over time, and you might have to repeat this step in the future to find it again. However, you can set a fixed IP address for your RPi with a little bit of effort. Please see Additional Notes #2 at the bottom of this article.
You can also choose to put in a little bit of extra effort so that your Pi can be accessed by name, instead of just by IP address.
Please refer to these URLs for instructions of how that works, and how to set it up:
How-To Geek: How to Assign the .local Domain to Your Raspberry Pi
Arne's Blog: How to setup mDNS lookups on the Raspberry Pi
3. Using SSH
Now that you have the IP Address for your RPi, you can connect to it from your PC by simply using SSH.
SSH is a feature that comes already installed in Raspbian (and most Linux systems, including Mac OS).
On Mac or Linux, open a Terminal window. The Terminal application can be found under Applications, in the Utilities folder.
In my case, my Raspberry Pi's IP Address was 10.0.1.10, so I typed the following command (followed by pressing 'enter', of course)
ssh pi@10.0.1.10
Non-Apple networks tend to use IP addresses in the 192.168 range, so yours may look more like:
ssh pi@192.168.2.2
It will then ask for your password (the default is "raspberry"). On that note, if your RPi is visible to the outside world, it's best to change that password to something else - ANYthing else.
In Windows, you can download an application named PuTTY (or similar Windows SSH client).
For the new session, enter the IP address and select SSH. Keep default port of 22.
You will now have command line access to your Raspberry Pi, conveniently from your PC!
All of the following steps can be accomplished from this SSH connection, from your PC.
4. Stop the GUI Desktop From Starting Automatically
Since you will be starting the GUI desktop for your Pi remotely on your PC, we don't want to start it automatically on the Pi when it starts, as that would unnecessarily use up precious memory and cause startup to take longer.
Use raspi-config to do this. At the command line, simply type the following command (followed by the enter key, of course)
sudo raspi-config
Because this is a task requiring root permissions, you need to use sudo, and you may need to enter your password.
This will start a text-based interface to allow you to change some of the Raspberry Pi startup settings.
Select the option "Enable Boot to Desktop/Scratch" and press 'enter' to select it.
Next, select the "Console - Text console, requiring login" option and press 'enter' to select it.
Now press the right-arrow key until <Finish> is highlighted, and press 'enter' again.
Press 'enter'' one last time to say 'yes' to rebooting.
If you are using SSH, your connection will close and you'll have to wait for your RPi to restart before you can login again. Restart will be faster now that the GUI doesn't need to be started
Note that you can always use "startx" to start the GUI manually when working directly on the RPi. You can also use the same steps (choosing to boot to GUI instead) to re-enable the auto-start of the GUI.
Intermission <pleasant intermission music goes here> ...
If you don't intend to ever use a remote GUI for your RPi, you can stop right here and happily go on using your RPi remotely using SSH. Note that you can still open GUI windows for individual applications using just SSH (See Note #5 below).
For the more graphically oriented amongst us, continue on, our goal is not too far away now...
5. Install the Remote Desktop Server software on the Raspberry Pi
The next step is to install the software on your Raspberry Pi that provides the connection to the Remote Desktop software that will run on your PC.
On the command line, type the following:
sudo apt-get install xrdp
Press 'y' when prompted to continue.
This will download and install the remote desktop server. This process can take a minute or two, depending on the speed of your internet connection.
6. Install the Remote Desktop application on your PC
Remote Desktop is an application by Microsoft, and is available for free in the Mac App store (and, I assume, as a download for Windows and Linux). Just search for "remote desktop". The app's name (in the Mac App Store) is "Microsoft Remote Desktop".
In Linux, you can install rdesktop (sudo apt-get install rdesktop), and for a graphical interface you can also install grdesktop (sudo apt-get install grdesktop).
I haven't checked on a Windows machine - it may already be installed, or you may have to download and install it now.
After installing Remote Desktop, open the application and add the following settings:
For PC name, type in the IP address for your RPi.
I also chose to uncheck "Start session in full screen" and I checked "Scale content", as I prefer to work with it inside of a window alongside the rest of the things I need to see when I'm on my main computer.
When you connect, it will open a window on your local machine that looks exactly like the GUI screen you would see when you log in directly on your RPi.
Done!
That's it, that's all you need to remotely access your Raspberry Pi using a convenient GUI window on your main PC.
Taking Over the World
Now that you know how to set up one Raspberry Pi with Remote Desktop, simply repeat the process so that you can have an army of RPis around the house all controlled via one computer in a secret lair!
Additional Notes
1* I found that the Remote Desktop App for Android does not work properly with Raspberry Pi. Maybe, hopefully, they will fix this in a future release.
2* Most home networks do not assign fixed IP addresses, so your Pi might get a new address at some point in the future. You could change your router settings to assign a fixed address to your RPi. How to do that varies, so check what is required for your router. Mac Time Capsule and Airport allow you to assign a fixed IP address to a machine based on Mac Address using Airport Utility. Other routers will likely have the same functionality implemented in their own special ways, so please check your router manual for those details.
OR:
You can also choose to put in a little bit of extra effort so that your Pi can be accessed by name, instead of just by IP address.
Please refer to these URLs for instructions of how that works, and how to set it up:
How-To Geek: How to Assign the .local Domain to Your Raspberry Pi
Arne's Blog: How to setup mDNS lookups on the Raspberry Pi
3* You can use FTP to move files to and from your RPi using similar settings. Use an FTP application like FileZilla.
4* From a Mac, you can use X11 to connect directly to an RPi without needing to install anything on the RPi. However, I found that this only allowed it to run in full screen, and kind of mixed with my Mac desktop.
5* You can also use SSH to open GUI windows for individual applications, without starting a complete GUI window for the RPi. Check out Enrico's post for more information.
6* Other alternatives to Remote Desktop also exist. Look for x11vnc and RealVNC. Complete instructions for setting up your Raspberry Pi with RealVNC are available at their website.
Top Comments