Eduroam on Raspberry Pi with Kodi

I wanted to make my Raspberry pi 2 into an entertainment system and quickly found that installing the LibreELEC operating system is an appealing option to run Kodi. Kodi is a nice interface to play videos and listen to music on a TV. The problem was that I only had the Eduroam wifi network available to me and it was not trivial for me to connect to it.

This tutorial contains instructions to connect to Eduroam at the University of Cambridge, but you might be able to use these instructions in other locations as well. This tutorial has been tested on Ubuntu 18.04, but may work on other Linux distributions as well. Throughout this tutorial, the commands I give are terminal commands, unless otherwise stated.

For this tutorial I assume that you have the following materials:

If you have no other networks available to you except for Eduroam, you will also need a router to connect your computer to your Raspberry Pi. One way to do things is to have a wifi enabled router so that you can set up a local network between your computer and the Raspberry Pi. In my case I used a router and two Ethernet cables, because I have a Raspberry Pi model B and a computer with an Ethernet port.

Preparing SD-Card

If you have used your SD-card before, you an follow the Backing up SD-Card section below to make a backup.

First, download NOOBS from the official Raspberry Pi website. Then we must partition our SD-card, by putting your SD-card into the reader and then plugging that into your computer. I found it easiest to format and partition through the gnome disks utility, which I open using the following command: gnome-disks

Within the Gnome Disks interface, click on the SD-card. Make sure your SD-card is selected and not any other drive, since you will loose all your data in the next step. Press Ctrl+F on your keyboard to format the selected disk. In the dialog that opens select "Quick" under Erase and "MBR/DOS" under Partitions. Once the formatting is done, we need to create our partitions. Still in Gnome Disks, we select our SD-card and click the + button. In the dialog that opens tell it to use the whole disk and click next. Enter any name that you like and select FAT for file system. After creating the partition, we need to mount this partition, which you can easily do in Gnome Disks by pressing the button with this symbol: ▶

Find the NOOBS image you downloaded earlier in your file manager and extract it. You will probably find your NOOBS image in your ~/Downloads folder. Go into the NOOBS_vX_Y_Z folder, select all the files and folders and copy those to the SD-card. The copying might take a few minutes. Make sure to go into the NOOBS folder instead of just copying the folder itself.

Installing LibreELEC

Now that we've prepared our SD-card, we can boot up our Raspberry Pi and install LibreELEC. Put your SD-card into your Raspberry Pi. Connect your monitor, mouse and power supply to your Pi. Once your Raspberry Pi boots up into the NOOBS installer click on the LibreELEC version that is suitable for your version of the Raspberry Pi. Wait until it's done and then reboot your Pi.

SSH into LibreELEC

Kodi allows you to control many settings via the graphical user interface, but connecting to Eduroam is something you cannot do. Therefore, we need to enable a Secure Shell or SSH, so that we can get a remote terminal on our computer. To enable SSH go to Kodi settings and click on LibreELEC. In the LibreELEC settings, under the "Services" tab enable SSH.

While we're in the LibreELEC settings, let's set the NTP servers which will be useful later on. Click on the "Network" tab and set the timeservers to:

0.pool.ntp.org
1.pool.ntp.org
2.pool.ntp.org

Now connect up your Pi to your computer. The way that I did it is connect the Pi and my computer via ethernet cables through a router. I connected them through a router, because the router provides DHCP, it is also possible to configure your computer to act as a DHCP server, but I will not cover that in this tutorial.

Once you've connected everything up, you can open a terminal on your computer to execute the following command while you replace ip_address_raspberry_pi with the IP address of your Raspberry Pi: ssh [email protected]_address_raspberry_pi This will prompt you for a password. The default root password for LibreELEC is libreelec

Setting the Time

Because our Raspberry Pi has never been connected to the internet, the time is set to the build time of LibreELEC. This may cause problems when trying to connect to Eduroam, because the system time might be outside of the validity period of the Eduroam certificate.

In our SSH session, you can set the date and time with the following command, where you change YYYY-MM-DD with the current year, month and day: date -s "YYYY-MM-DD 00:00:00" This command will fix the time, but it will not persist across boot cycles. To fix this we can create a file that executes the command at each boot. Execute the following command nano /storage/.config/autostart.sh And put the date command that we used earlier into that file (to exit nano use the keyboard shortcut CTRL+X and confirm with y). Lastly, we have to make this autostart script executable using the following command chmod +x /storage/.config/autostart.sh

Connecting to Eduroam

Now we are finally ready to connect to Eduroam, it's been a pain but we're nearly there. On your computer download the Eduroam certificate. For the University of Cambridge the certificate is locate here. Just in case that link ever breaks, I found it through this page.

In a different terminal (not the one with SSH), we need to copy our certificate to the Raspberry Pi. First navigate to the place where you downloaded the certificate, for example: cd ~/Downloads/ Afterwards, use the following command to copy to the Pi, replacing ip_address_raspberry_pi with the appropriate IP address: scp wireless-ca.crt [email protected]_address_raspberry_pi Again, the default root password is libreelec

Back in our SSH session, we can now start to configure our wireless interface for Eduroam. First, let us check whether we have a wireless interface, by checking that there is wlan0 under: ifconfig Now we connect a configuration file with the following command nano /storage/.cache/connman/connman-service.config Please put the following content in this file:

[service_wifi_eduroam]
Type = wifi
Name = eduroam
EAP = peap
CACertFile = /storage/wireless-ca.crt
Phase2 = MSCHAPV2
Identity = [email protected]
AnonymousIdentity = [email protected]
Passphrase = your_passphrase

Make sure to replace your_username with your username, which at the University of Cambridge is your CRSid. Also, fill in your passphrase in for your_passphrase. At the University of Cambridge, we have a special wireless token that you need to fill in here, which you can find by logging into the UIS Tokens page.

After exiting nano (Ctrl+X and y), let's type the following command: connmanctl enable wifi and then scan for the nearby wifi networks: connmanctl scan wifi You can see a list of discovered networks through the following command: connmanctl services There should be a *A in front of the Eduroam network, if there isn't then there is something wrong with your connman-service.config. In the output of the previous command there is a code next to eduroam looking something like, where the ellipsis are replaced by hexadecimal digits: wifi_..._..._managed_ieee8021x Copy that output and put that in the following command: connmanctl connect wifi_..._..._manage_ieee8021x

That's it! You should be connected to Eduroam now and your Pi should connect on each boot. If you chose to set your time to 00:00:00 like I did, you can detect whether it connects to the internet by seeing the time change once the Raspberry Pi can connect to the NTP servers. Sometimes, it fails on the first try and you can tell it to retry in Kodi by going to settings, LibreELEC, and Connections.

Don't forget to disable SSH after you are done configuring. You can do this in Kodi by going to settings, LibreELEC and Services. I hope you enjoyed this tutorial and using your Raspberry Pi as an entertainments system on Eduroam.

Bonus: Backing up SD-Card

To back up your SD-card put your card into the reader and plug it into your computer. Use lsblk to find the device name of your SD-card reader, it should be something like sdb or sdc, without a number at the end. Make sure to check that the size matches your SD-card's size.

Before we can back up our SD-card, we must unmount all of its partitions. You can do this using the following command. Make sure to change your_sd_device for the device name that you found in the previous step: umount /dev/your_sd_device*

Once we've unmounted the SD-card, we can make a backup of the SD-card. Be sure to change your_sd_device to the device name from the first step and /path/to/backup.img to the path and file that you want the backup to be written to. You will probably need sudo in front of this command, because it wants direct access to a device in the /dev folder. dd if=/dev/your_sd_device of=/path/to/backup.img bs=4M

If you want to verify your backup you can use the following commands and check whether they both output the same sha256 hash value: dd if=/dev/your_sd_device | sha256sum and dd if=/path/to/backup.img | sha256sum Finally, if you would ever like to restore your backup you simply reverse the arguments given to dd: dd if=/path/to/backup.img if=/dev/your_sd_device bs=4M