PIA with OpenVPN on Raspberry Pi

Here is a quick guide on setting up OpenVPN with PIA VPN (Private Internet Access)

I am running Raspbian Jessie Lite on a Raspberry Pi 3, i will also be investigating running this with OSMC in the future.

First off we need to ensure your Pi is up to date and install the OpenVPN software

sudo apt-get update
sudo apt-get install openvpn

Once installed make sure you are in the pi users home directory

cd /home/pi

create a new folder called pia_profiles and navigate into that folder

mkdir pia_profiles

cd /home/pi/pia_profiles

Download the PIA profiles from Pia website, the download is a zip file

wget https://www.privateinternetaccess.com/openvpn/openvpn.zip

Extract the files

unzip openvpn.zip

Now we need to copy some files over to the openvpn install folder

sudo cp crl.rsa.2048.pem /etc/openvpn/crl.rsa.2048.pem
sudo cp ca.rsa.2048.crt /etc/openvpn/ca.rsa.2048.crt

The zip file you extracted contains all the profiles for various servers that PIA use. I personally use a UK one but you can use anything, for this example i will use the UK London profile.

sudo cp "UK London.ovpn" /etc/openvpn/pia.conf

Navigate to the OpenVPN install location

cd /etc/openvpn

We need to create a login conf file, this way you can keep your username and password out of the configuration files.

sudo nano login.conf

Type your PIA username and password on seperate lines and save the file (normally Ctrl+O)


Change the permissions on the file so all users can read the file (this step might not be needed but its what i do)

sudo chmod 755 login.conf
sudo cmod 755 pia.conf

Edit the pia.conf file for the PIA connection

sudo nano pia.conf

At the bottom add the following line

auth-user-pass login.conf

The file should look similar to this (the remote line will be different based on the profile you used)

dev tun
proto udp
remote uk-london.privateinternetaccess.com 1198
resolv-retry infinite
cipher aes-128-cbc
auth sha1
remote-cert-tls server
verb 1
reneg-sec 0
crl-verify crl.rsa.2048.pem
ca ca.rsa.2048.crt
auth-user-pass login.conf

Before we start the VPN connection its best to check your current external IP, you can do this by running

curl ifconfig.co

Note the returned IP address, now start the VPN by using the following command

sudo systemctl start openvpn@pia.service

Run curl ifconfig.co command again and see if the output is different. If it is then great you are connected, if it isnt then something isnt right and i would suggest reviewing the steps above.

If you wish to run this upon boot then use the below command

sudo systemctl enable openvpn@pia.service

To disable running this at startup run this command:

sudo systemctl disable openvpn@pia.service

You can also run openvpn interactively by running

openvpn pia.conf

Running it interactively is useful to diagnose problems but obviously you can call it from a script.

FileBot on Raspbian Jessie

Recently my Raspberry Pi had a corrupt partition on the SD card so i was forced to reinstall from scratch.  Although i had a backup of my scripts i had to download and configure the applications i was using.

I noticed when i was browsing my previous blog post on FileBot that the version i was using is no longer available.  As such i have decided to write a new blog post outlining what is needed to get the latest version working.

First off if you dont know what FileBot is its a really great app that automates the renaming of TV shows and Movies.  I use it to automatically rename files and move them to my NAS so OSMC will automatically detect and add them to the library.  For more information have a read of the FileBot website.

FileBot requires Java run time, im not going to go into details on how to set this up but i personally used this blog post and it worked for me:


Im using Raspbian Jessie Lite, from my understanding if you are using the full Raspbian Java is already included but you might want to check that.  You can run the following command to check:

java -version

Once Java is setup we we need to ensure you are in the pi home directory

cd /home/pi

Create a new directory in here, this will store the FileBot application

mkdir filebot

We need to download the latest version of FileBot, from my research the ipk file i was using in my previous blog post doesnt exist and the version that does exist gives an error in regards to a blacklist.xml file not being found on the internet.

The latest version doesnt include an ipk version, as such we will use the portable version as that includes the filebot.jar and the filebot.sh script we need.

The downloads are located here: https://sourceforge.net/projects/filebot/files/filebot/

Look for the latest “portable.tar.xz” version and download it to your pi home directory

wget https://sourceforge.net/projects/filebot/files/filebot/FileBot_4.7.9/FileBot_4.7.9-portable.tar.xz

Extract the files from the tar to our filebot folder

tar xpvf FileBot_4.7.9-portable.tar.xz -C /home/pi/filebot

Thats it, we can now call filebot via a script pointing your script to /home/pi/filebot/filebot.sh


/home/pi/filebot/filebot.sh -rename path/to/episodes

There is some great command line documentation available on the FileBot website here: http://www.filebot.net/cli.html

Setting up FileBot TV Renamer on a Raspberry Pi

Update 09/06/2017

This post is outdated as the version listed doesnt exist, the version that does exist doesnt work properly for some reason.  As such i have written a new blog page showing how to get the latest version working with Raspbian Jessie Lite.

FileBot on Raspbian Jessie

FileBot is a File Renaming Utility specifically designed for renaming TV shows. The application is available for lots of different platforms including Windows, Mac, Linux and even NAS devices.   We are interested in the Embedded Linux package as this contains everything needed to get it up and running on Raspbian.

This guide assumes you already have the latest version of Raspbian setup and running on your Raspberry Pi.

First off we will create a folder in your home directory to store the download, the download is an IPK which we will need to extract after it has been downloaded. NOTE: at time of writing 4.5.6 was the latest version, best to check the FileBot website to see if there is a later version available)

mkdir filebot

cd filebot

Then run this command to download the application

wget http://sourceforge.net/projects/filebot/files/filebot/FileBot_4.5.6/filebot_4.5.6_arm.ipk

Once downloaded we will need to extract the files in the IPK, to do this we will use the AR utility.

sudo ar -x filebot_4.5.6_arm.ipk

This will extract the contents of the file into our filebot folder, type LS to see a folder list and you will see a new file called “data.tar”

sudo tar -xvf data.tar

This will extract contents of the tarball and put the contents into our filebot folder, type LS again and you will see a new folder called “opt”.  We must now copy the contents of the opt folder into that system /opt/ folder to ensure this works correctly.  NOTE: you can edit the filebot.sh script (located in the /opt/share/filebot/bin/ folder) and run this from any location you wish however for ease of use i am going to install this application into the location specified in the script.   Run the following to copy the share folder into /opt/

sudo cp ~/filebot/opt/* /opt/

We should now change the ownership on the FileBot folder, this is an optional step but without it you will have to invoke your script with the sudo command to ensure the FileBot directories are written to correctly.  To change the ownership run the following command:

sudo chown -R pi /opt/share

We now need to create a script which runs the filebot.sh script and pass some arguments in, the FileBot CLI web page as a list of the available commands and it is well worth a read to understand what this utility can actually do.  For myself i have a simple script which renames any media in a download folder called TV and moves the media after it has been renamed to a folder called TV Shows on my NAS.  This is setup as a source in OpenElec which means new media is scanned into my library.  To create my script create a folder called scripts in your home directory

mkdir scripts

cd scripts

We must then create our script, call it what ever you want

nano tvrenamer.sh

We must then create our script, i am going to use the following arguments

My script is below, this script runs filebot.sh and makes the application look at my transmission downloads folder, renames them with the format “Series NameSeries # x Episode #Title” and moves the media file to a folder with the Series Name/Season #. It uses “thetvdb” for the metadata to ensure the correct show and data is picked, i have also added the date and time to the script so when my cron task runs it updates the log file with the date and time.


DATE_STAMP=’date +%d-%m-%Y-%T’
echo ${DATE_STAMP}

/opt/share/filebot/bin/filebot.sh -rename /mnt/downloads/transmission/complete/TV/* –format “/mnt/videos/TV Shows/{n}/Season {s}/{n} – {sxe} – {t}” –db thetvdb -non-strict

Save the script, make it executable and run the script to test

sudo chmod +x tvrenamer.sh


This script can then be run via a cron schedule to ensure media is renamed automatically, i run this every 30 minutes.  To do this edit the crontab by entering the command

sudo crontab -e

At the bottom of the file add the following line, this runs the script every 30 minutes and creates a log file of the output so you can view any problems.

*/30 * * * * ~/scripts/tvrenamer.sh >> ~/scripts/tvrenamer.log 2>&1

Enjoy your automated renaming system, if you wish you can clean up the downloaded files from earlier by running

sudo rm -fr ~/filebot