Install and Configure OpenVPN on OSMC/Kodi

Let’s face it, Kodi is pretty popular right now, everyone is talking about it. One of the first things I did after I installed OSMC on my Raspberry Pi was to configure OpenVPN. There is a little bit of work involved so I figured I’d share what I did to get it up and running!

Login to OSMC via SSH using PuTTy or your client of choice.

Elevate to Super User.
osmc@KODI:~$ sudo su

Update the software repositories.
root@KODI:/home/osmc# apt-get update

Install OpenVPN.
root@KODI:/home/osmc# apt-get install openvpn

root@KODI:/home/osmc# reboot

Create a folder to put your OpenVPN configuration files in.
osmc@KODI:~$ sudo su
root@KODI:/home/osmc# mkdir vpn-conf

Copy your .opvn file/files and your .crt file into /home/osmc/vpn-conf, there are a few ways to copy the files here, I personally like to use PSCP. This
example is using PSCP from a Windows computer.
C:\temp>pscp c:\temp\ca.crt osmc@

Create a new file that will contain your login credentials for OpenVPN
root@KODI:/home/osmc# cd vpn-conf
root@KODI:/home/osmc/vpn-conf# vi login.conf

  • Press Insert
  • Type your Username on first line press enter and type your password on the next
  • Press Esc, type :wq

Now edit the .opvn file/files of choice to make sure the login.conf and <ca_file_name>.crt file are referenced correctly.
root@KODI:/home/osmc/vpn-conf# vi <filename>.ovpn

  • Find the following lines that begin with:
    • auth-user-pass
    • ca
  • If they exist – edit them accordingly, if they don’t exist you will need to add them.
auth-user-pass /home/osmc/vpn-conf/login.conf
ca /home/osmc/vpn-conf/ca.crt

Let’s test out OpenVPN, the service should start and connect successfully after running this command.
root@KODI:/home/osmc/vpn-conf# openvpn /home/osmc/vpn-conf/<filename>.ovpn

Confirm VPN connectivity by using curl, this should retrieve your VPN’d IP address.
root@KODI:/home/osmc/vpn-conf# curl

If everything checks out and is working so far it’s time to install the OpenVPN Add-On for
Kodi and import a profile. Grab the latest OpenVPN Add-On for Kodi, the quickest way is to just grab it is to use wget right from OSMC, using your web browser right-click on the and Copy the link address.
root@KODI:/home/osmc/vpn-conf# wget -c <paste_link_addr_here>

From Kodi on your TV, go to Settings -> Add-ons -> Install from zip file

  • Select Install from zip file.
  • Navigate to the ZIP file and select it.
  • In the bottom right corner, Kodi notifies when the add-on is installed and enabled.

Now the OpenVPN Add-On for Kodi should be installed… go to Programs > Add-Ons
> OpenVPN from Kodi and import your .opvn files, once complete try to connect. It should work successfully since it’s literally just an interface to the actual OpenVPN service that we just installed and configured.

That’s it! …but if you’d like to take it one step further you can. I personally like to have a certain OpenVPN profile connect at startup of Kodi. It’s pretty simple to do this.

Browse to the userdata folder for Kodi and create an file.
root@KODI:/home/osmc# cd /home/osmc/.kodi/userdata
root@KODI:/home/osmc/.kodi/userdata# vi

  • Type the following where <profile_name> is the profile
    name of the profile you have created in the OpenVPN Add-On for Kodi.
import xbmc

Now every time you power on your Kodi box, OpenVPN will launch and the VPN
profile of choice will connect automatically. Cheers and happy streaming!


42 thoughts on “Install and Configure OpenVPN on OSMC/Kodi

Add yours

  1. Hello, what are the username and password? Is that from OpenVPN Access Server Client license subscription? Thx!

    1. The username and password are the credentials that are provided by your VPN provider. Typically you can log in and retrieve these from your VPN provider’s website.

      1. Thanks for your prompt reply.
        Any good VPN provider you can recommend?
        Just curious, any good and reliable Free VPN provider for OSMC/Kodi?

      2. There may be some, I’ve never personally tried a free one. My concern would be around the bandwidth and the ability to stream video with a free provider. My guess is it would be hard to find a free provider that would be lag free upon streaming, if there was such a provider everyone would be jumping on board. There are quite a few quality providers, many people I know recommend PIA, Private Internet Access ( There are certainly many more providers out there, I use TigerVPN and it’s ok for the most part, sometimes though it does get a bit choppy when streaming.

      3. i know i am late, but how do you login and get the username and password, i tried everything and never got anything

  2. Thanks again for the prompt reply. Will try ut your solution on my Pi 3.
    Really enjoy your blog!

  3. Great write up, thank you! For the auto start, I keep getting:
    # python
    Traceback (most recent call last):
    File “”, line 1, in
    import xbmc
    ImportError: No module named xbmc

    Any idea what can be causing this? I’m using OSMC build and everything works well manually.

    1. The only thing I can think of is it can’t be run outside of xbmc. If you are calling it from outside of xbmc you will see an import error.

      1. It’s being called within XBMC. I did figure out the python script works on start up, just doesnt work when manually calling it.

  4. Hi,
    Great write up. I have an issue though. The addon doesn’t seem to find openvpn program. After successfully importing and naming my configuration when I click on it I get an error about openvpn not being found. When I run openvpn by hand it connects. Where should the binary be?

    1. According to the documentation there should be an option in the OpenVPN add-on to set the binary location. By default it looks in /usr/bin/openvpn

      Set this to the OpenVPN binary.
      Default: /usr/bin/openvpn

      1. Hi ! I have the same problem but I don’t understand where it should look if it isn’t in /usr/bin/openvpn

      2. Ok it’s in /usr/sbin as Osay said sorry ^^, but still got the message “unable to connect to openvpn management interface”.
        Anyway if I can’t get it working this way I’ll be fine with the launching openvpn at startup, so thx for your nice tuto.

      3. I meant at linux startup with a rc.local script. Working fine btw. sorry for spam

  5. Hi,
    Never mind. I had to make the addon point to /usr/bin/openvpn instead of /usr/sbin/openvpn.

    1. Update: While I can get the SSH commands to work, I wasn’t ever able to get the app working. Says it’s Connecting to.. which is 99% further than I ever got before but when I check the IP using the command above.. it’s my usual IP. But the shell commands work to initiate the connection? So I am not sure why the app doesn’t work given I was able to establish a VPN. Regardless, fantastic tutorial. It’s really not that easy using OSMC and even their forums don’t have anything this useful.

      1. That’s strange, do I understand this correctly? When you run the commands from SSH it works but from the OpenVPN add-on it won’t connect? The only thing I can really think of is maybe a file permission issue? That is a weird scenario.

    2. Before I found this guide, I emailed IPVanish to ask how to configure it with OSMC and a Raspberry Pi. They told me it wasn’t possible.

      Well, I have it running! Fools.

      Am I OK to send them a link to this guide? Maybe they can use it.

      1. Haha glad to hear it worked for you, that interesting they’d say it was not possible… I guess we proved them otherwise 🙂 go ahead and share the knowledge.

  6. Thanks for this great tutorial. I have completed all steps,but when I attempt to Import my opvn files nothing is show (even though the files are in the vpn-conf directory and have I successfully completed a VPN connection manually. I see one network location when I attempt to import the opvn files, but not vpn-conf. I have checked the “Run as Sudo” option and left the “require password” option blank. So I’m not sure what I’m missing. Any assistance will be greatly appreciated.

    1. The only thing I can think of is maybe the read/execute permission on the opvn files, try “chmod 555 “

  7. I keep getting tis error. any ideas?
    Options error: –tls-auth fails with ‘ta.key’: No such file or directory
    Options error: Please correct these errors.

    1. perhaps your ovpn file calls for a ta.key but you didn’t actually include it in your vpn-config folder? my ovpn files didn’t require a ta.key file because the authentication wasn’t as thorough as some i’ve seen and frankly i was happier for an easier setup. try removing the line in your ovpn file calling the ta.key and see if that works. i had options for my VPN that had a ta.key and some that didn’t and i just used the ones that didn’t…

  8. great guide, unfortunately when i try to move files into the folder vpn-conf it densies me the permission, either with pscp or filezilla and cyberduck

    1. Sounds like a permissions issue, check the permissions on the folder and make sure you are using elevated privileges.

  9. Thanks for publishing this awesome article. I’m reading your blog since a long
    time already but I never compelled to leave a comment.
    I registered your blog in my rss feed and shared it on my Twitter.
    Thanks again for this great post!

  10. HI, thanks for this works great up to where i have to configure OpenVPN on the Kodi via TV. When i’ve installed and opened the addon it asks me for a configuration file, and only lets me look in two locations on storage. I’ve added the .ovpn file but it still asks me for a config file. Any thoughts ? Thanks, Stu

    1. the configuration file is the ovpn file (that’s been altered to reflect an accurate path to it and the credentials file). it should work as long as you have the correct path(s) in it….

  11. I have the OpenVPN running perfectly on kodi….but for the part, I ran the code and nothing happens at startup. do i have to put the openvpn path in the 2 lines of code to get it to work? maybe its something else…

  12. Hey there,
    Thanks for your smooth configuration guid. however, I have a minor issue. I follow up the steps and everything works fine, until here: “Now the OpenVPN Add-On for Kodi should be installed… go to Programs > Add-Ons> OpenVPN from Kodi and import your .opvn files”. when I opened the OpenVPN Add-On there is no .opvn files. I looked up inside the existing folders but I was not able to find .opvn files which I was configured. Do you know what went wrong or did I miss something?

    1. Hi,
      I also had this issue, you need to go into file browser and click on the magnifying glass then navigate to the vpn-conf folder that holds your ovpn files (in the home directory). Hope that helps.
      I’m not sure it worked for me though, I ran through all the steps but im not sure the add on i got is the right one. Going to try another one from the Zomboided repository and if that doesn’t work, I’m giving up on osmc and going over to libreelec as ive seen a guide to get openvpn working on that.

      Hope you have some success!

  13. Hi,
    After using your instructions to Install and Configure OpenVPN on OSMC/Kodi (ATV1) couldn’t get connected to PureVPN service andmy Mac Terminal shows some errors that I don’t understand:

    osmc@osmc:/$ cd /home/osmc/vpn-conf
    osmc@osmc:~/vpn-conf$ openvpn London1UK.ovpn
    Mon Oct 2 18:57:25 2017 OpenVPN 2.3.4 i586-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Jun 26 2017
    Mon Oct 2 18:57:25 2017 library versions: OpenSSL 1.0.1t 3 May 2016, LZO 2.08
    Mon Oct 2 18:57:25 2017 WARNING: file ‘/home/osmc/vpn-conf/login.conf’ is group or others accessible
    Mon Oct 2 18:57:25 2017 WARNING: No server certificate verification method has been enabled. See for more info.
    Mon Oct 2 18:57:25 2017 WARNING: file ‘/home/osmc/vpn-conf/Wdc.key’ is group or others accessible
    Mon Oct 2 18:57:25 2017 Control Channel Authentication: using ‘/home/osmc/vpn-conf/Wdc.key’ as a OpenVPN static key file
    Mon Oct 2 18:57:25 2017 UDPv4 link local (bound): [undef]
    Mon Oct 2 18:57:25 2017 UDPv4 link remote: [AF_INET]
    Mon Oct 2 18:57:28 2017 [PureVPN] Peer Connection Initiated with [AF_INET]
    Mon Oct 2 18:57:31 2017 ERROR: Cannot ioctl TUNSETIFF tun: Operation not permitted (errno=1)
    Mon Oct 2 18:57:31 2017 Exiting due to fatal error

    Thanks in advance for your help

  14. Hi, thanks for the tuto, it worked fine for me.
    However, I wish to automatically reconnect to VPN in case of network loss. Do you know a script able to do that? (in a similar way than connection at startup, as you suggested)

  15. Have you ever considered creating an e-book or guest authoring on other sites? I have a blog based upon on the same ideas you discuss and would really like to have you share some stories/information. I know my readers would appreciate your work. If you are even remotely interested, feel free to send me an e-mail.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a free website or blog at

Up ↑

%d bloggers like this: