Thursday, March 03, 2016

Remote Desktop & Remote Control Raspberry Pi

Introduction

This article discusses how to log into a Raspberry Pi Remote Desktop from a Windows machine and how to Remote Control a Raspberry Pi from a Windows machine.

Remote Desktop Raspberry Pi from Windows

Remote desktop allows you to log into a desktop (i.e. X-Windows session) on your Raspberry Pi. If you have the Raspberry Pi connected to a physical monitor, you will not be logging into that desktop, but a new desktop that will be dedicated to your remote desktop session. For instructions on how to remote control the Raspberry Pi from Windows, see the second half of the article.

Setup Raspberry Pi for Remote Desktop

  1. Startup the Raspberry Pi.
  2. Open a terminal prompt.
  3. Enter the following command to install xrdp (http://www.xrdp.org/):
    sudo apt-get install xrdp

    You may be prompted for your password (the default password for the Raspberry Pi is “raspberry”).
  4. Reboot the Raspberry Pi. The Remote Desktop Protocol server (xrdp sesman) should automatically start on reboot.
  5. Get the IP address of the Raspberry Pi. This can be done by executing the following command from a terminal prompt:
    ifconfig

Connect From Windows Machine

  1. Start the Remote Desktop Connection application.
    • On Windows 7 click Start, All Programs, Accessories, Remote Desktop Connection.
    • On Windows 10 click Start and enter Remote Desktop Connection.
  2. Enter the IP address of the Raspberry Pi in the “Remote Desktop Connection” dialog and click Connect.
  3. When connecting you may see one or more of the following dialogs:


  4. Once connected, a login dialog will be displayed.
  5. Enter a username and password. The default Raspberry Pi username is pi and the default password is raspberry.
  6. Once you are logged in, you should see the Raspberry Pi desktop.

Remote Control Raspberry Pi from Windows

Remote controlling allows you to control the currently active desktop (i.e. X-Windows session) on your Raspberry Pi. With this technique, you can control (e.g. manipulate the mouse & keyboard) the desktop that is shown on the physical monitor that is connected to the Raspberry Pi.

Setup Raspberry Pi for Remote Desktop

  1. Startup the Raspberry Pi.
  2. Open a terminal prompt.
  3. Enter the following command to install x11vnc (http://www.karlrunge.com/x11vnc/):
    sudo apt-get install x11vnc
  4. Enter the following command to set the vnc password. This is the password users will need to enter to remote control the desktop.
    x11vnc –storepasswd
  5. You can test the x11vnc server by entering the following at a terminal prompt.
    x11vnc –usepw
  6. You should see a message like the following on the terminal.

Connect From Windows Machine

  1. Install a VNC client. In this example I use TightVNC Viewer (http://www.tightvnc.com/download.php).
  2. In the VNC client, enter the IP address of the Raspberry Pi followed by a “:” and the display number, which can be found terminal window running x11vnc (this will normally be a 0, but in our example above this is a 2).
  3. Enter the password that was used when setting up x11vnc.
  4. You should now be able to see and interact with the Raspberry Pi desktop.

Automatically Startup x11vnc on the Raspberry Pi

  1. Create the directory ~/.config/autostart, if it does not already exist. This can be done using the following terminal command.
    mkdir –p ~/.config/autostart
  2. Create a text file in this directory, called xterm-autostart.desktop. You can create and edit this file with the following terminal command.
    leafpad ~/.config/autostart/xterm-autostart.desktop
  3. Put the following text into this file.
    [Desktop Entry]
    Encoding=UTF-8
    Name=x11vnc autostart
    Comment=Starts the x11vnc server to allow for remote VNC connections.
    Exec=x11vnc –forever -usepw
  4. Reboot the Raspberry Pi.
  5. Once the Raspberry Pi desktop appears, you should be able to remote control the Raspberry Pi using a VNC Client.

No comments: