NOTE! This site uses cookies and similar technologies.

If you not change browser settings, you agree to it.

I understand

Welcome, Guest
Username: Password: Remember me

TOPIC: How to set up a VPN using Brian Hornsby Openvpn addon

How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 month ago #1

  • invisable
  • invisable's Avatar
  • Offline
  • Senior Boarder
  • Posts: 105
  • Thank you received: 27
  • Karma: 5
HOW TO SET UP YOUR VPN CLIENT
## Note : To set up autostart and auto switching see post #2
This is a guide on how to get your VPN working on your Raspberry pi using Brian Hornsby OPENVPN for XBMC I have tested this and it works on Rpi B and 2B this also works on the openelec versions of xbmc on the Hummingboard so it will work on the cuboxi and most likely the wetek This does not work on Apple TV due to it not having a openvpn client installed also this only works on Gotham and later builds of openelec
This guide assumes that you know the basics and you know how to move files and i have tried to make this a simple as possible, I mention about using the built in file manger to transfer files, but you can use what you like, I used my ftp client and also edited my files using nano, rather then notepad ++
Thanks to all involved in this thread as it originally brought the method of editing the files to my attention, also thanks to Brian Hornsby the developer for writing the addon.

I use Private internet access as my VPN provider so i am using them as an example for this guide. Please note If you are also using using private internet access you may need to generate a password for socks, pptp to use on this guide, this can be done by logging into pia and clicking generate password from the client control panel.

step 1:
First thing you need to do is download your clients vpn configuration including the certificate files if needed. for PIA they can be download from thislink:
https://www.privateinternetaccess.com/openvpn/openvpn.zip

There are a couple of free openvpn services don't know how good they are but if you want to set up a free one you could try these:
http://freevpn.me/accounts
the certificate files are usually included in the .ovpn files


Step 2:
Once your VPN configuration files have been downloaded extract it to a folder on your computer.(I created a folder on the desktop and extracted them there)


Step 3:
Open up the folder where you extracted all your configuration files to and remove all the spaces in the names of the locations you want to use, so for example.
CA North York.ovpn would become CANorthYork.ovpn

Step 4:
Open up notepad++ if you havent got this it is free to download from here
http://notepad-plus-plus.org/download/v6.6.7.html
on the first line you need to type your username (nothing else)
on the second line type your password (nothing else)
click file and save it as pass.txt (make sure it is a txt file)this should be saved into the same folder where you extracted your VPN configuration files.

Step 5:
open up one of the openvpn configuration files you want to use for example this is USMidwest.ovpn from PIA
it will look like this:
client
dev tun
proto udp
remote us-midwest.privateinternetaccess.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
tls-client
remote-cert-tls server
auth-user-pass
comp-lzo
verb 1
reneg-sec 0
crl-verify crl.pem
You need to edit the lines beginning with ca ca.crt and auth-user-pass.
Also we need to edit the last line "crl-verify crl.pem" so it looks like this:
client
dev tun
proto udp
remote us-midwest.privateinternetaccess.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca /storage/.config/vpn-config/ca.crt
tls-client
remote-cert-tls server
auth-user-pass /storage/.config/vpn-config/pass.txt
comp-lzo
verb 1
reneg-sec 0
crl-verify /storage/.config/vpn-config/crl.pem
what we are doing here is telling the ovpn file where to find your certificate and login details. (Sometimes the certificate is inserted into the openvpn file so you will not need to edit the line that starts with ca)

If you are also using Private Internet Access you could save yourself sometime and download my already edited ovpn files from here
http://www.mediafire.com/?2gid36chazkt4

Step 6:
repeat the process of step 5 to all the ovpn configuration files you want to use from within xbmc

step 7:
once you have modified all the .ovpn/.conf files that you want to use it is time to move them onto your pi.(there are many ways to do this but the easiest way for those who really dont know is just to put the files on a usb stick (fat32) that way you can plug it into your pi).

On xbmc go into settings>apperance>file lists and make sure "show hidden files and directories" is checked.
next open the filemanager in xbmc, click on add source a window will pop up.
click "Root filesystem" it will open up lots of folders ignore this just press the OK box.
it will now take you back, click on the box at the bottom where it says "Enter a name for this media Source" name it Root then click OK at the bottom

step 8:
if you know what your doing the *.ovpn files you edited along with your pass.txt and the ca.crt need to be transferred onto you pi into /storage/.config/vpn-config if you dont understand this carry on reading this step.
On the xbmc file manager you should see the new source in window which is called root click on this on WINDOW A, on the left.
WINDOW A (LEFT SIDE)
now click on: storage
now click on: .config
now click on: vpn-config
this folder will be empty but if you look under the big letter A you can see it is listed /storage/.config/vpn-config

WINDOW B (RIGHT SIDE)
next put in your (fat32) usb stick into your pi and wait a couple of seconds for the pi to recognize it and you should see it pop up in WINDOW B on the left side of your TV screen
go into the location on the usb stick where transferred all of your edited ovpn files, your pass.txt ad the ca.crt file.
bring up context menu over each of the files and select copy it will now appear in window A
it is important that you copy all the files across including pass.txt ca.crt

Step 9:
IMPORTANT.
We now need to install the Openvpn binary THIS IS NO LONGER INSTALLED BY DEFAULT.

from the Kodi menu Go-to -System > Add-ons > Install from repository > OpenELEC Media centre OS Add-ons > Add-on repository> then install the unofficial openelec repo for your system.

Once installed..
Go back a few places so your on the "install from repository page" again
Open. Unofficial Openelec ## add-ons > Program add-ons >openvpn (and install).

step 10:
log into your pi using putty
username: root
paswword: openelec

we need to check your work so at the command prompt type: openvpn /storage/.config/vpn-config/whatever_your_vpn_is_called.ovpn
so as the name of the vpn you edited so as we edited USMidwest.ovpn we would type
openvpn /storage/.config/vpn-config/USMidwest.ovpn
the VPN service should start, if it completed successfully you will get a message saying so and you will have to exit out of your ssh client


step 11:
so if all is successful you now have a working VPN if you wanted to check that your connected to you vpn run the hub maintenance tool and there is a option to check you ip address and location.
Anyway now we need to install the openvpn script it can be found here:
http://brianhornsby.com/xbmc_addons/openvpn
( click on BLUE ICONs under github)

step 12:
Once you have installed the script go to programs highlight the openvpn script and bring up the context menu and select addon-settings.
we now need to tell the addon where the openvpn client is so it can run the script so on the first page click on the box where it says "openvpn"
you will need to back up by selecting the .. or pressing the backspace key untill you can back up anymore.
Select "Root file system"
then select the folder "storage"
select the folder ".kodi"
select "addons" then "network.openvpn" then "bin" and finally "openvpn" and click ok
in the box the path that should be writen should be
/storage/.kodi/addons/network.openvpn/bin/openvpn


step 13:
now all that is left to do is import you ovpn files, in the addon-setting select import openvpn file and import your edited ovpn files, it will ask you to name them to what you want.
once you have imported all the locations you want to use, run the addon and select your chosen location. to dissconnect open up the addon again and select disconnect at the bottom

Good luck and don't forget to keep a backup of all your edited files !!!
The openelec backup tool doesn't backup any of the content from the .config folder so I always manually take a copy of this folder that way its easy if anything happens to your system.




Sent from my HTC One using Tapatalk
Please excuse my spelling and grammar
Last Edit: 1 year 10 months ago by invisable.
The administrator has disabled public write access.
The following user(s) said Thank You: Scope, dieselshroom

Re:How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 month ago #2

  • invisable
  • invisable's Avatar
  • Offline
  • Senior Boarder
  • Posts: 105
  • Thank you received: 27
  • Karma: 5
Extra options that you may like to setup..

If you automatically want to connect to a chosen location each time Kodi boots up the easiest way to do this is to create a autoexec.py script.
kodi.wiki/view/Autoexec.py

This can be created using your chosen editor and placed in the userdata folder.
As a example if I wanted Kodi to connect to my France server everytime it boots my autoexec.py would look like this.
import xbmc

xbmc.executebuiltin('XBMC.RunScript(script.openvpn,France)')
IMPORTANT the script should be written over 2 lines like on the Kodi wiki page. Also "France" is the name given when imported into Brians addon and not the name of the actual Ovpn file.

If you want your VPN to automatically connect to different locations when opening up addons Like IPlayer for example.
Then you may want to check this thread and service addon, which was created by marv_el
forum.kodi.tv/showthread.php?tid=222196
Last Edit: 1 year 6 months ago by invisable.
The administrator has disabled public write access.

How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 month ago #3

  • Shazb0t
  • Shazb0t's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 14
  • Karma: -1
I am currently using PIA on my RPi2 using Metal Kettle's PIA for Openelec add on which automates this process for easy setup. It works great in 5.0.8 but is broken in the 5.95 betas. Per a tweet from Metal Kettle he says it no longer works in the Betas because Openelec has removed some features. Does your method work with 5.95? If not, why is Openelec breaking VPN support in the newer versions? I would like to continue to use a VPN in the future.
The administrator has disabled public write access.

How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 month ago #4

  • chewitt
  • chewitt's Avatar
OpenVPN was removed from the core build and recreated as a binary addon in the unofficial repo. Aside from that (and removal of our GUI which never worked in the first place) nothing changed.
The administrator has disabled public write access.

Re:How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 month ago #5

  • invisable
  • invisable's Avatar
  • Offline
  • Senior Boarder
  • Posts: 105
  • Thank you received: 27
  • Karma: 5
Yes as chewitt said this method works fine. This guide was originally written for Openelec 5 on another site but I waited until now to post it here because this is modified for Openelec 6

Sent from my HTC One using Tapatalk
Last Edit: 2 years 1 month ago by invisable.
The administrator has disabled public write access.

Re:How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 week ago #6

  • Beechnut
  • Beechnut's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 7
  • Karma: 0
Followed guide faithfully. All went well until I tried to Ssh the Pi. I get an " openvpn : not found " after I type in the command line to connect to pia vpn. Also after install of Brian's openvpn script , which install without issue. Under the openvpn settings , the guide tells me to point to /usr/bin/openvpn. But when I try to that directory it's not there. There is NO openvpn directory under bin. Working a few hours this, need a little push in right direction.
The administrator has disabled public write access.

Re:How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 week ago #7

  • chewitt
  • chewitt's Avatar
The binary will be somewhere under /storage/.kodi/addons/ now that we removed openvpn from the core build and repackaged it as an addon.
The administrator has disabled public write access.

How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 week ago #8

  • jan
  • jan's Avatar
  • Offline
  • Junior Boarder
  • Posts: 61
  • Thank you received: 7
  • Karma: -1143
FYI here's a link to the ipvanish forum with an other approach, which seems to be working
IpVanish & OpenElec
didn't tried it myself though
The administrator has disabled public write access.

How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 week ago #9

  • Beechnut
  • Beechnut's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 7
  • Karma: 0
Thank you for the response. I actually had the unofficial openelec opennvp installed and figured stupidly that it wasn't needed when I installed Brian's wonderful openvpn script. I mean I don't need two openvpn add-ons right......wrong! Once reinstalled it WORKS!

If you would be so kind could you point me in the right direction for setting the vpn to start on boot up. Been doing a little research and I'm finding way too many options to do this with pia vpn.

Thanks in advance
The administrator has disabled public write access.

Re:How to set up a VPN using Brian Hornsby Openvpn addon 2 years 1 week ago #10

  • invisable
  • invisable's Avatar
  • Offline
  • Senior Boarder
  • Posts: 105
  • Thank you received: 27
  • Karma: 5
Beechnut wrote:
Thank you for the response. I actually had the unofficial openelec opennvp installed and figured stupidly that it wasn't needed when I installed Brian's wonderful openvpn script. I mean I don't need two openvpn add-ons right......wrong! Once reinstalled it WORKS!

If you would be so kind could you point me in the right direction for setting the vpn to start on boot up. Been doing a little research and I'm finding way too many options to do this with pia vpn.

Thanks in advance
Read post #2 about setting up a autostart, your see an example in the code box, just edit it to suite your needs.
You can create a autoexec.py in nano, vi or notepad ++ if you prefer

The other alternative is to create a autostart.sh script but in my opinion it's easier to do the autoexec.py method as you don't need to mess around with sleep commands, kodi will automatically execute it when it's good and ready.

The guide on this thread was written for Openelec 6, it's slightly different (steps 9 & 12) from the one on the faq page on Brian's site as that was written before the binary was removed.

Sent from my HTC One using Tapatalk
Last Edit: 2 years 1 week ago by invisable.
The administrator has disabled public write access.

How to set up a VPN using Brian Hornsby Openvpn addon 2 years 4 days ago #11

  • leedavid
  • leedavid's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
  • Karma: 0
I just want to report that everything works with TorGuard too.
The administrator has disabled public write access.
The following user(s) said Thank You: invisable

How to set up a VPN using Brian Hornsby Openvpn addon 1 year 11 months ago #12

  • SanJM
  • SanJM's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 1
  • Karma: 0
Hi,

Used your method and works perfect, thanks for your article :) , only one question, I needed to reboot after creating the connection with Putty (step 10) and installing step 11 (openvpn), before I put the addon settings location/ import, it created a script error if I didn't. After a reboot it went ok.

Other question, how safe is it to put my VPN pass.txt on my RPI2 openelec. Its not encrypted so a hacker can see my log name and pass of my VPN provider in a worst case. :unsure:

So far I now it's not possible to change SSH log and password, so is it wise to shut off SSH on my RPI2, have some doubt about security

Much thanks

San
Last Edit: 1 year 11 months ago by SanJM.
The administrator has disabled public write access.

Re:How to set up a VPN using Brian Hornsby Openvpn addon 1 year 11 months ago #13

  • invisable
  • invisable's Avatar
  • Offline
  • Senior Boarder
  • Posts: 105
  • Thank you received: 27
  • Karma: 5
SanJM wrote:
Hi,

Used your method and works perfect, thanks for your article :) , only one question, I needed to reboot after creating the connection with Putty (step 10) and installing step 11 (openvpn), before I put the addon settings location/ import, it created a script error if I didn't. After a reboot it went ok.

Other question, how safe is it to put my VPN pass.txt on my RPI2 openelec. Its not encrypted so a hacker can see my log name and pass of my VPN provider in a worst case. :unsure:

So far I now it's not possible to change SSH log and password, so is it wise to shut off SSH on my RPI2, have some doubt about security

Much thanks

San

I'm not sure about the first issue, think you would have to look at the log file for an answer but if it's working fine now then I wouldn't worry to much.

As for the second issue, I'm not sure if there is a way to encrypt the pass.txt file on OpenElec because it's an embedded system. on other distributions you could try something like "chmod go-rwx pass.txt" which should only let the user who created the file read & write to it, but like I said not sure it would work on OpenElec.
hopefully someone with more knowledge may prove me wrong.

I suppose anything is possible when it comes to hacking. Not sure why anyone would want to hack a Rpi2 with the sole purpose of running Open Elec but you never know.
One step you could take to protect yourself would be not to install any dodgy repo or addon. If your really worried then I would say it's easier to shut down once finished, then worry about it ;)

Can I ask why you can't change your ssh logging password ?



Sent from my HTC One using Tapatalk
The administrator has disabled public write access.

Re:How to set up a VPN using Brian Hornsby Openvpn addon 1 year 11 months ago #14

  • SanJM
  • SanJM's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 1
  • Karma: 0
Hi Invisable,

Thanks for reply, the issue is not big, only wanted it to mention for other users, using this on three RPI2, Openelec 5.0.8. After the step where I need to import the .opvn files I just need to reboot to prevent a sript-error, it happens when I import the location, name the location and press ok.

About security I forgot one big thing that I am able to generate an extra name and password with PIA specially for this, so the only thing that a hacker can do is to use openvpn or pptp protocols with my name and not to login my account.
For instance I also stream from my protected NAS server and need to put a user/ pass to set the location, that pass is encrypted. It only would give an extra level of protection, and yeah if a hacker want to come in your system we always run behind with our security.

Brian's openvpn script works much better than the VPN pptp protocol for PIA that you can use with openelec (openelec/ network/ add new VPN) because of the lack of switching easily to other locations. also easier to create an autostart.

Big thanks
The administrator has disabled public write access.
The following user(s) said Thank You: invisable

How to set up a VPN using Brian Hornsby Openvpn addon 1 year 11 months ago #15

Hello There!

First of all thank you very much for this tutorial.
I have a problem running openvpn.
Whatever I write after the command, or even if I write anything at all, I always get this error message:

/storage/.kodi/addons/network.openvpn/bin/openvpn: line 1: syntax error: unterminated quoted string

Does anyone have a solution for me?

THX
NDI
The administrator has disabled public write access.