[HOWTO] OSMC/Rasp Pi as OpenVPN client

Wanted to thank everyone in earlier thread as it gave lots of good info. I will try to document what I had to do, hopefully it will help someone else to setup with PIA (I am not affiliated with PIA)

1 Install openvpn

sudo apt-get update
sudo apt-get install openvp

2 Make directory OpenVPNConfig to store all the files

mkdir ~/OpenVPNConfig
cd ~/OpenVPNConfig

3 Download and extract OpenVPN Configuration Files (Default) from PIA Support Portal

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

4 Easiest way is to get the files without spaces. Make sure you are in OpenVPNConfig directory (pwd)

cd ~/OpenVPNConfig
rename “s/\s+//g” *

5 In the same directory create pass.txt with your PIA credentials:

username
password

6 Update all your PIA files with this oneliner to the location of your files. In my case I have installed in /home/osmc directory, if your home directory is different just replace the path (make sure you have everything on one line. The sed will make a backup of all your files, when you verify all looks good, just remove all files with .bak extension

sed -i.bak -e ‘s/ca\ ca.crt$/ca\ /home/osmc/OpenVPNConfig/ca.crt/g’ -e ‘s/auth-user-pass$/auth-user-pass\ /home/osmc/OpenVPNConfig/pass.txt/g’ -e ‘s/crl-verify$/crl-verify\ /home/osmc/OpenVPNConfig/crl.pem/g’ -e ‘s/crl-verify\ crl.pem$/crl-verify\ /home/osmc/OpenVPNConfig/crl.pem/g’ *.ovpn

7 Install Kodi OpenVPN plugin as in http://brianhornsby.com/kodi_addons/openvpn

NOTE: You will need to configure after installation path to openvpn from

/usr/bin/openvpn
to
/usr/sbin/openvpn

and enable “run with sudo”

8 Now it is a good time to check if your vpn actually works:

sudo openvpn ~/OpenVPNConfig/{yourpreferredVPNprofile}.ovpn

If all works you are now to move into GUI.

9 Copy all your config files to Kodi openvpn config: I chose to just copy and replace files as needed (symlinks may work too, did not test)

cp ~/OpenVPNConfig/*.ovpn /home/osmc/.kodi/userdata/addon_data/script.openvpn/

10 Test in KODI if you are able to connect, disconnect from VPN. If all looks good, then you may also prefer to start PIA on boot. For that I copied Pedro_Diogo instructions above, however I modified VPN startup from:

openvpn /{YOUR_PATH}/{yourOwn}.ovpn

to:

  • Connect to your preferred VPN in KODI
  • Get the entire command as KODI openvpn users with ‘ps aux |grep openvpn’
  • Now replace that entire command in “/etc/init.d/startOpenVPN” config file.

On every reboot you will connect to PIA automatically and if needed you can always disconnect with KODI openvpn client and reconnect as needed.

1 Like