Press "Enter" to skip to content

OpenVPN setup for private internet access (PIA VPN) Raspberry Pi 3 OSMC

I recently started using OSMC on my Raspberry Pi. I also have an account with private internet access which is, by the way, the best VPN service you can get hands down in my opinion. This tutorial will show you how to setup OpenVPN to connect to private internet access at boot up of your OSMC / Debian-based Linux.

  • Things to do
  1. Enable SSH on OSMC /Debian-based Linux, update, upgrade, install network-manager-openvpn, and install openvpn.

If you do not know what SSH is Google is your friend. Secure Shell. I’m going to leave out some stuff because I assume you already know the basics
and I don’t want to turn this tutorial into a book such as how to find your IP address on your OSMC box how to SSH and etcetera. However, if you have questions leave comments and I would be more than happy to help you there are no dumb questions. A helpful link  Accessing the command line on OSMC,

Okay SSH into your OSMC/Debian-based Linux If this is the first time SSHing into your OSMC I HIGHLY recommend changing the default password of the OSMC. The default Login and Password is osmc. To do so Type in your SSH Client.

passwd osmc

  • now we start It’s always a good idea to have your OSMC up-to-date and we are going to install OpenVPN.

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install network-manager-openvpn
sudo apt-get install openvpn

  • I did all the work inside /etc/openvpn You don’t have to but this is how the tutorial is written

cd /etc/openvpn

  • Download private internet access VPN zip and unzip

sudo wget

sudo unzip

  • Now try and connect to the VPN of your choice ending in ovpn. For me, I’m going to be using Sweden.ovpn (note If you choose one of the files that has spaces in it like example UK London.ovpn rename it to Something that has no spaces in it for example UK London.ovpn to UK_London.ovpn. To do that #sudo mv UK\ London.ovpn /etc/openvpn/UK_London.ovpn)

sudo openvpn –config ./Sweden.ovpn

  • It’ll ask you for your username and password. Enter these and hopefully, you get ‘Initialization Sequence Completed’. you need to press CTRL -c to cancel the sequence and take control again. After this, you need to change the config to keep your User and Password in it.

sudo nano /etc/openvpn/login.conf

Add 2 lines for login and password line one is going to be your private internet access login and line two is going to be your password. To save and exit Nano press CTRL -x it will ask you to save it type Y


  • Set the proper permissions for the conf file

sudo chmod 400 /etc/openvpn/login.conf

  • Create a new config file with the Sweden information from the Sweden.ovpn And we’re going to name the new config file  pia_sweden.conf

sudo cp Sweden.ovpn /etc/openvpn/pia_sweden.conf

  • By adding the new line OpenVPN automatically knows where to grab the password.

sudo nano /etc/openvpn/pia_sweden.conf

  • At the line auth-user-pass add login.conf so it looks exactly like auth-user-pass login.conf

  • Now let’s see if all our work paid off. Your username and password are automatically accepted

sudo openvpn pia_sweden.conf

  • You should get the ‘Initialization Sequence Completed’ again and no interaction. press CTRL -c to stop it.
  • To make it work on start up we need to change the startup file for openvpn. and add a line to it AUTOSTART=pia_sweden

sudo nano /etc/default/openvpn

  • Now reboot your OSMC

sudo reboot

  • Then to make sure it’s working and to find your external IP. log back in via SSH

wget -O – -q ; echo

  • or


  • Now it automatically connects to your VPN on boot up of your system. I hope you find this tutorial helpful


Note the best place for help is


  1. Warren Harding
    Warren Harding September 1, 2017

    should be: sudo apt-get install network-manager-openvpn
    not: sudo apt-get install network-manger-openvpn


    • Bruce
      Bruce September 2, 2017

      Thanks for catching that one

  2. Avip Toyou
    Avip Toyou September 21, 2017

    Extremely helpful. Thank you very much!

    P.S. the “manger” typo is still in one more not-important spot — the top bullet

    • Bruce
      Bruce September 21, 2017

      Nice eye thank you.

  3. Heideroosje
    Heideroosje December 29, 2017

    Recent versions of OSMC come with connman instead of NetworkManager.
    Does this imply I have to get rid of Connman first and install NetworkManager to follow this tutorial?

    • Bruce
      Bruce December 29, 2017

      I don’t think it’s going to be an issue, I just SSH into my Pi and I looked at my IP and everything seems to be working with that configuration.
      But I would check out this form and ask him there sorry that I can’t help more I’ll look into it though.

  4. John John
    John John December 30, 2017

    This was incredibly helpful and worked the first time I tried it. Thanks so much!

    • Bruce
      Bruce December 30, 2017

      Happy it worked 🙂

  5. Ray
    Ray January 13, 2018

    Very helpful and straightforward. Thanks!

  6. Arnaud
    Arnaud January 27, 2018

    This was working perfectly, untill the OSMC update from December 2017. Now the log seems to be indicating that everything works but I don’t have a connection and curl only works when the vpn is not working. Any idea on what is needed to solve this issue?

Leave a Reply

Your email address will not be published. Required fields are marked *