Using a VPN on OpenELEC is something that many people find is necessary because they want to either unblock geo-restricted material or they want to make sure their ISP or anyone else can’t see what they are doing online. Follow along to see how you can use IPVanish with your OpenELEC Kodi HTPC.
Before we start there are a few pre-requisites you need in order for this to work correctly.
- IPVanish Account – You will need this as your VPN provider. They’re the only Tier-1 premium bandwidth VPN company and their service is amazing. They have over 225 servers in 60+ counties. They keep no logs and are 100% anonymous.
- SSH Client – I use and recommend PuTTY – Look for ‘putty.exe’ and save that somewhere
- The IP of your OpenELEC HTPC. You can get this by going to System -> Hardware -> Summary and looking for ‘IP Address’. Make note of this.
So lets start by logging into your IPVanish account and grabbing the OpenVPN config files. You will need a few files included in the zip, but not every single one of them. Once you login click on Server List, the click OpenVPN to download ‘configs.zip’
Since you can only be connected to one VPN server at a time, we can actually remove all the .ovpn files except for one. What I recommend doing is choosing a VPN profile that is in the same state/country you are in so that you’ll get the best speed possible. That, or if you are looking to unblock geo-restricted content, then choose the country that is unblocked. Seeing as how I am in Canada, I use a VPN server in the USA to watch USA based content that is blocked for Canadians.
[alert-success]Get IPVanish VPN for $6.49 per month – Unlimited VPN with No Logging![/alert-success]
What you should be left with is the following
Now that we have those two files, we need to make some modifications so that it will work with OpenELEC. First thing we need to do is modify the .ovpn file. If you see anything you’re unsure about (file paths, names etc) it should all make sense and come together at the end. Open it up in notepad (or TextPad or Notepad++) and make the following changes:
- Change the 4th line – ‘remote ipvanish.server 443’ to ‘remote ipvanish.server 1194’
- Change the 10th line – ‘ca ca.ipvanish.com.crt’ to ‘ca /storage/.config/vpn-config/ca.ipvanish.com.crt’
- Change the 12th line – ‘auth-user-pass’ to ‘auth-user-pass /storage/.config/vpn-config/pass.txt’
- The steps below are optional, they’re needed if you’re experiencing slowness (this lowers the encryption)
- Comment out line 18 – So put a ‘#’ at the start of the line
- On line 19 (under the line we just commented out) put the following – tls-cipher DHE-RSA-AES128-SHA
Your config when finished should look like the following:
[sourcecode language=”plain” highlight=”4,10,12,18,19″] client
dev tun
proto udp
remote ipvanish.server 1194
resolv-retry infinite
nobind
persist-key
persist-tun
persist-remote-ip
ca /storage/.config/vpn-config/ca.ipvanish.com.crt
tls-remote ipvanish.server
auth-user-pass /storage/.config/vpn-config/pass.txt
comp-lzo
verb 3
auth SHA256
cipher AES-256-CBC
keysize 256
#tls-cipher DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA
tls-cipher DHE-RSA-AES128-SHA [/sourcecode]
Note that if you copy and paste that, it won’t work. I’ve removed the server addresses.
Once you have saved that the next step is to create a file called ‘pass.txt’ that has the following 2 lines:
- username
- password
That’s it. All you need in there is your IPVanish username and password, each on it’s own line.
At this point you should have the following 3 files in your directory:
- ca.ipvanish.com.crt
- ipvanish-*.ovpn
- pass.txt
Now what we’ll need to do is copy these 3 files on to our OpenELEC Kodi box. There is a wiki page here outlining how you can connect to the Samba shares on your OpenELEC machine – http://wiki.openelec.tv/index.php/Accessing_Samba_Shares. Since I’m on Windows I just need to open up a Windows Explorer window and type \\IP.Address\ and press enter. The IP address is the IP I gathered earlier (from the pre-requisites!)
Once that is open, navigate to \\IP.Address\Configfiles\vpn-config and copy our 3 files there.
Excellent! We’re almost there.
Next up is we need to test our VPN connection to make sure it’s working correctly before we continue on. Let’s fire up our SSH client PuTTY or whatever you choose. Enter in the IP of the OpenELEC machine in the ‘Host Name’ field and click Open.
When you get the login prompt use the following credentials:
- Username: root
- Password: openelec
If it all went well you’ll be presented with the following
Now don’t be freaked out by the linux terminal. We’re not doing anything crazy here 🙂
Let’s first navigate to where we saved those three files earlier.
Type the following and press enter:
[sourcecode language=”plain”]cd /storage/.config/vpn-config/[/sourcecode]
Once you do that you can type ‘ls’ and press enter to see if they’re all there.
Great, looking good so far.
Let’s do a quick little test to see what our current IP is, so we can test it against the new one to make sure we’re connected.
Type the following and press enter:
[sourcecode language=”plain”]curl ifconfig.co[/sourcecode]
It should print out an IP address. That should be your current external IP. It will be the same as if you went to whatismyip.com or something similar.
Now let’s connect to the VPN manually to ensure everything is working. From the command line (and from the directory we changed to with the ovpn file) we need to run the following:
Type and press enter:
[sourcecode language=”plain”]openvpn ipvanish-[server].ovpn &[/sourcecode]
Note: Please note that you will need to replace the [server] with the actual file name. Also note the ‘&’ at the end, this will allow us to go back to the command line once it’s connected.
A little protip is you can start typing the file name and press the Tab button to autocomplete, so just type ‘ipva’ or something and press Tab to autocomplete the name for you.
Once you see something like this: Sun Oct 25 16:23:00 2015 Initialization Sequence Completed, you can press the Enter key to bring you back to the command line.
Now once again you can type the following and press enter:
[sourcecode language=”plain”]curl ifconfig.co[/sourcecode]
It should now be different! You’re now connected to IPVanish on your OpenELEC HTPC!
Start Up Script
So that was fun and all but let’s finish this off properly with adding this to an autostart script that will connect us to the VPN whenever we start OpenELEC Kodi.
From your SSH client type the following and press enter:
[sourcecode language=”plain”]nano /storage/.config/autostart.sh[/sourcecode]
Once we’re in the text editor all we need to do is copy in the following script. You can highlight the below script and copy/paste it into Putty. In order to paste, make sure you have the text copied to your clipboard, click on Putty, and right click. This should paste it all into the text editor. From there you will need to modify it slightly to suit your exact .ovpn file.
[sourcecode language=”plain”]
(
openvpn /storage/.config/vpn-config/ipvanish.server.config.file.here.ovpn
) &
[/sourcecode]
Now the final thing to do is to reboot OpenELEC and then re-login to the SSH client and run the ‘curl ifconfig.co’ command again to grab our IP to see if it’s still the VPN IP.
Hope that helps with using a VPN with Kodi. I highly recommend you use one if you’re a big online streamer. The VPN will allow you to view it all anonymously which is becoming more and more important these days. Pay a few dollars a month to protect yourself to ensure you’re never the target of anything. I use it on my home setup and recommend it to everyone.
Let me know how it works out for you in the comments, or if you’re having any issues.
Thanks!
IPVanish, which is the only true Tier-1 VPN service in the world. IPVanish allows you to surf the net anonymously as well as access geo-blocked content in Kodi. You'll be able to watch anything unrestricted. They have clients for Windows, OS X, iOS and Android. OpenVPN is an option as well. Remember to use your IPVanish VPN with Kodi!
I’m getting ready to build an HTPC and came across your site, it is very helpful btw. The following statement from one of your articles made me scratch my head.
“The VPN will allow you to view it all anonymously which is becoming more and more important these days. ”
Why is it important?
Thanks,
Richard
It’s more of a personal opinion to be honest Richard. It’s not mandatory, by any means, but quite often in the news you see people getting letters from their ISP or letters from lawyers who are out to extort money from them. If you have the means to encrypt your activities and protect your activity from people who want to monitor you, then why not take advantage of it.
Thanks so much for providing this guide. We love giving our users a variety of options for using our service!
Is this also working on a Raspberry PI2 with openelec?
Yes, if it is OpenELEC, then it should work on all platforms. Thanks
I’m trying with Openelec raspberry pi and I’ve gotten it to connect, but cannot make autostart work, but it must be something simple. Only tried the last hour or so.
I’m not sure if this is necessary but try doing the following:
Thanks!
I’m having the same problem. Followed your instructions above however the autostart script won’t initiate the VPN.
Are you using openelec? which version? have you looked at the logs?
got it to work upto openvpn ipvanish-[server].ovpn &
then second from last line reads
AUTH: Received control message: AUTH_FAILED
Please double check that your ‘pass.txt’ file contains your proper IPVanish login. It also needs to be in the format where your username is on the top line and your password is on the bottom line.
pass.txt as you say.
I would open up a ticket with IPVanish. This sounds like an authentication issue with them.
got it all working fine through putty but when trying the auto start commands and re booting no autostart.Tried the commands provided to jesper holm on oct 27 but still the same.
if i look in my openelec config files after autostart commands and re boot, i have 2 files.
autostart.sh.save
autostart.sh.save.1
This worked, … well sort of. 🙁
when I run the openvpn ipvanish-[server].ovpn & command, it sometimes hangs/pauses until I press Return. It then continues to churn out ‘stuff’ a line of which states ‘Deprecated TLS cipher name ‘DHE-RSA-AES256-SHA’, please use IANA name ‘TLS-DHE-RSA-WITH-AES-256-CBC-SHA”
If I manage to quit the process, and Curl – I do get a different. ip address (sometimes)
Is the output ‘Deprecated …. etc’ standard or is it erroneous?
Also, for some reason, the autostart doesn’t appear to be working. I’ve tried the chmod suggestion above – but it still doesn’t seem to work.
Sorry if i’ve missed something – I’m new to rpi/vpn/linux etc. etc.
Hey,
For your ‘deprecated’ error you can try the following: When I tell you to comment out a line in the ovpn config, don’t do that 🙂 lol, just leave it ‘as-is’ how you get it from IPVanish.
Hi Alex – I’ve now commented out the tls-cipher DHE-RSA-AES256-SHA etc. etc. and it seems to have worked 🙂
Now I need the autostart to work. I’ve followed the instructions (? :-)) but it doesn’t seem to work. 🙁
Any suggestions?
I would look into the Kodi autostart wiki page (where I got my info from) and see if it helps. You could also post to the Kodi support forums to see if there is something else you will need to do. Unfortunately I don’t know what else to tell you. I’m glad it’s working for you now though!
Thanks Alex – your help is much appreciated! 🙂
I’m at the point where I must type in:
openvpn ipvanish-[server].ovpn &
and for whatever reason, I keep getting:
OpenELEC:~/.config/vpn-config # openvpn ipvanish-MYSERVERNAME.ovpn &
OpenELEC:~/.config/vpn-config # -sh: openvpn: not found
I’m in the correct directory and the file is there:
OpenELEC:~/.config/vpn-config # ls
ca.ipvanish.com.crt pass.txt
ipvanish-MYSERVERNAME.ovpn
Thanks!
What version of OpenELEC are you running?
5.95.5 6.0 Linux 4.1.6
kodi 5.1
Looks like you’re running the beta version of OpenELEC, which may not have the OpenVPN binaries on there. You may need to post to the OE forums to see if you can have OpenVPN installed.
Thank you sir!
I was able to get vpn installed via unofficial openelec repo. then when manually started vpn, it worked! Although, on reboot to try and test the autostart, openelec updated itself to 6.0. Now, weirdly, when I try to manually start vpn, I get this:
OpenELEC:~ # openvpn ipvanish-MYSERVERNAME.ovpn &
OpenELEC:~ # Options error: In [CMD-LINE]:1: Error opening configuration file: ipvanish-MYSERVERNAME.ovpn
Use –help for more information.
Autostart doesn’t work either.
After getting ‘OpenELEC:~ # openvpn ipvanish-MYSERVERNAME.ovpn &
OpenELEC:~ # Options error: In [CMD-LINE]:1: Error opening configuration file: ipvanish-MYSERVERNAME.ovpn’ error I tried ‘openvpn /storage/.config/vpn-config/whatever_your_vpn_is_called.ovpn’
That worked but can’t get auto-start to work – I’m on openelec 6.0
You sir, are the man! Thank you for this amazing yet simple to follow tutorial.
Do you know I’ve previously contacted IPVanish on how to use their service on OpenELEC and was told the only way was via router configuration (and only certain routers work btw)
You’d think that a professional company like IPVanish would have an addon dedicated for Kodi users, huh? (Or would at least provide instructions like this)
This is the reason why I’ve been using OpenELEC with VPNicity instead for quite some time now. Works flawlessly and it has a GUI interface to change servers at any time via their Kodi addon. Simplicity at its finest.
But, thanks to your tutorial, I can now compare the two services and see how they stack up against each other. Thanks again!
Worked great for me on opelelec6 ! worked right the first time, autostart included!! great, many thanx.
Excellent! So happy it all worked for you.
Hi, I’ve got my files ready to try this out later when I can SSH into my Pi 2. One question is when I use IPVanish on android/windows/mac, I can chop and change VPNs easily. Is there no way to facilitate this through this method? If I only put one VPN in, I’m tied to that and have to replace that line in the file via SSH every time I want to choose another server. This will be a huge pain if I’m choosing a VPN for geo-unlocking and get a slow one or the same locally within my country. If we put all the servers in rather than just one, could we select from that list at all?
I’ve followed the instructions but when I’m in Putty and type:
openvpn ipvanish-[server].ovpn & (using the appropriate server details)
I get:
-sh openvpn: not found
Pi 2 running OpenElec 6.0 / Kodi 15.2. I note though that when I type:
curl ifconfig.co
the IP address it comes back with is not the static IP of the Pi 2 but some random address – does this mean it is already going through the IPVanish servers?
Right, I’ve got openvpn installed on the Pi now and now when I run the openvpn ipvanish-MYSERVER.ovpn & line, I get:
lines about DEPRECATED cipher names
pass.txt is group or others accessible
RESOLVE: Cannot resolve host address: ipvanish-MYSERVER: Name or service not known
Given that I am using that service as I type this, this is odd.
I could really use some help with this please!
im getting the same issue saying not found ive tried everything im lost right now
I tried changing the vpn server from one in germany to one in the uk and i get the same response – a response surely would be nice!
Extreme thanks!!! I’ve been trying get a VPN to work on my openelec setup forever.
Hi Alex,
I’m at the point where I must test the VPN manually.
The following error message I receive:
OpenELEC:~/.config/vpn-config # openvpn /storage/.config/vpn-config/ipvanish-[MYSERVER].ovpn &
[1]- Done(2) openvpn ipvanish-[MYSERVER].ovpn
OpenELEC:~/.config/vpn-config # /storage/.kodi/addons/network.openvpn/bin/openvpn: line 1: syntax error: unterminated quoted string
cd /storgae/.kodi/addons/network.openvpn/bin/
I’m installing it op a Pi2, Openelec 6.0, Kodi 15.2 and Openvpn 6.0.0 (author Stefan Saraev) is installed and enabled.
Could someone help me?
For all of you that might have problems with the startup script this fixed my issues.
According to http://openelec.tv/forum/90-miscellaneous/63050-getting-a-script-to-star-at-boot
autostart.sh runs before networking is available.
This means that it is necessary to force the startup script to wait for some seconds in the background before the openvpn command is executed. i did this by adding sleep 15 to the original script:
(
sleep 15
openvpn /storage/.config/vpn-config/ipvanish.server.config.file.here.ovpn
) &
I hope this works for you guys as well 🙂
Thanks, this worked for me!
Your instructions worked flawlessly! Thank you.
The only thing I did not do was the auto script. I have a few premium addons that only work with my real ip address. That said, I’m stuck with having to manually launch it when needed. As of now, I’m running IPVanish via SSH from my linux terminal in laptop. No biggie, but what other alternatives are there for manually running the VPN? If I wanted to run it directly from within OpenELEC without the need of my laptop… what are my choices?
openvpn not found…
Does anyone know of a way to install OpenVPN into codesnake’s port of openelec 6.0 for the MX boxes?
I’m drawing a blank here.
Well for those of you saying “OpenVPN not found” you need to enable it from the unofficial OpenELEC repository.
On that note, now since following these instructions if I connect the VPN, I then cannot access the box remotely anymore. It just times out.
What’s the deal?
ifconfig.co moved to ifonfig.ca
Overall the guide is good!
OpenELEC has an section to configure vpn via Programs-> OpenELEC Configureation->Network->Virtual Private Network
But it is “problematic”.
It has an option to use an ovpn configuration file, but it does not actually uses it…
You still have to fill everything manually.
Shame, would save so much time!
I’m getting the following error
OpenELEC:~/.kodi/addons/network.openvpn # openvpn ipvanish-AU-Melbourne-mel-c01.ovpn
Tue Feb 7 12:10:50 2017 DEPRECATED OPTION: –tls-remote, please update your configuration
Options error: Unrecognized option or missing parameter(s) in ipvanish-AU-Melbourne-mel-c01.ovpn:22: auth-user-pass/storage/.kodi/addons/network.openvpn/pass.txt (2.3.9)
Use –help for more information.