This tutorial is about establishing remote desktop connection from laptop to Raspberry Pi. This tutorial mainly dedicated for those don't have HDMI monitor for Raspberry Pi. You will use your laptop monitor as Raspberry Pi monitor by using remote desktop (xrdp & remmina). This tutorial makes use of Raspberry Pi 3. Thanks to Juang Nakarani for lending me a HDMI monitor and kindly teaching me remote desktop.
- xrdp (Raspberry Pi)
- remmina (Laptop)
- nmap (Laptop) (optional)
- Correct settings in /etc/network/interfaces (Raspberry Pi)
- A Raspberry Pi 3 with Raspbian operating system.
- A WLAN router, an Android phone for example.
- Internet access from WLAN router.
- A laptop with Ubuntu operating system.
- Write Raspbian image into a microsd card. Read How To Write Raspbian.
- Create a USB tether WLAN hotspot from your Android phone. We name its SSID as ubuntero and WPA-PSK and its password as netrunner.
- Access your already bootable microSD from your laptop. Access it until you can read /etc/network/interfaces file inside the microSD. That is the configuration file for Raspbian. Don't edit the /etc/network/interfaces from your own Ubuntu system.
- Backup the interfaces file by doing command sudo nano /the/path/to/interfaces /the/path/to/interfaces-backup
- Edit the interfaces file by doing command sudo nano /the/path/to/interfaces.
- Enter the correct settings like the example below. Essentially, you need to provide SSID name and password from your Android hotspot.
1. Correct Settings
This is the original default setting of /etc/network/interfaces file in Raspbian:
# interfaces(5) file used by ifup(8) and ifdown(8) # Please note that this file is written to be used with dhcpcd # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback iface eth0 inet manual allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf allow-hotplug wlan1 iface wlan1 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
And this is the example setting of /etc/network/interfaces file for this tutorial:
# interfaces(5) file used by ifup(8) and ifdown(8) # Please note that this file is written to be used with dhcpcd # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' # Include files from /etc/network/interfaces.d: #source-directory /etc/network/interfaces.d auto lo iface lo inet loopback auto wlan0 iface wlan0 inet dhcp wpa-ssid "ubuntero" wpa-psk netrunner
Note: you should change the ubuntero into your own hotspot SSID, and change the netrunner into your hotspot password. Basically you just need to add 4 lines (from auto wlan0 until netrunner) and it is safe to delete from the original the 7 lines (from iface eth0 until wpa-supplicant.conf).
What those settings do in Raspberry Pi is to automatically detect and connect into your Android WLAN tethering hotspot. Because the Raspberry connects to the hotspot and your laptop connects to the same hostpot, you can login from your laptop into the Raspberry Pi. We need it because we have no monitor for Raspberry Pi.
2. Boot Raspberry Pi
Now connect power into your Raspberry Pi until it boots. You will see the two indicator leds blinking. Wait for about 1 or 2 minutes until Raspberry Pi can connect automatically into your Android hotspot.
3. Find Raspberry Pi IP Address
Now you must install xrdp in the Raspberry Pi so it will be the server for your laptop. To reach it, the only one way to do it is by remote login from your laptop into the Raspberry Pi. You may use ssh (openssh, already installed by default in Ubuntu) to remote login into Raspberry Pi. This is allowed because laptop and Raspberry Pi are in the same network (from your Android hostspot). Firstly, you should know what is the IP address of your Raspberry Pi. For this, we use nmap. In your laptop perform these series of commands:
You should see your WLAN interface (wlan0 or such) has an IP address. My laptop IP address is 192.168.43.201. My laptop gets this IP from my Android hotspot. Basically, any other host will have the same range of IP such as 192.168.43.2xx. You may guess yourself that Raspberry Pi gets 202. But for any purpose you may use nmap command below:
nmap -v 192.168.43.202-210
That nmap command scans your network (Android hotspot) for any other host connected from number 202 until number 210. See picture below, nmap finds a host named raspberrypi with IP address 192.168.43.202. This is my Raspberry Pi. And with the same method you will find your Raspberry Pi too.
4. SSH Login from Laptop
Now from your laptop, you should control your Raspberry Pi in case of installing xrdp. From your laptop, login to Raspberry Pi with ssh (openssh, already installed built-in in Ubuntu) command below. Note: default username for Raspbian is pi with password raspberry.
Now you must see Raspbian shell prompt like this pi@raspberrypi: ~$ if you have logged in correctly into Raspberry. You will see a notice text saying you are using GNU/Linux. To exit, just type command exit. See picture below.
5. Install xrdp in Raspberry Pi
Now from your shell in laptop (already logged in remotely to Raspberry Pi), perform these commands:
sudo apt-get update sudo apt-get install xrdp
Explanation: first command will reload your Raspbian to download the index files from the Raspbian repository. Second command will install xrdp and its dependencies for your Raspbian. Note that these two commands executed in Raspberry Pi not in your laptop.
6. Install Remmina in Laptop
Now back to your laptop. Open a new Terminal and install Remmina with this command:
sudo apt-get install remmina remmina-plugin-rdp
7. Setup Remmina in Laptop
Open Remmina. Set some configuration like these.
- Type your connection name. You may type any name, e.g. your cat name is okay. In this example, I give it name Raspberry Pi di Rumah.
- In Server: field, type IP address of your Raspberry Pi. In this example, 192.168.43.202.
- In User name: field, type pi.
- In Password: field, type raspberry.
- In Resolution: field, choose Use client resolution.
- In Color depth field, choose High color (16 bpp).
8. Remote Desktop from Laptop to Raspberry Pi
Now select your connection entry in Remmina and press Connect button. If there is a simple window asking pi password, enter raspberry and OK. You will see Remmina shows your Raspbian desktop from Raspberry Pi. Now, your laptop monitor is your Raspberry Pi monitor. Congratulations!