Updated July 25 2019
This tutorial will show you how to set up OpenVPN to be used with PIA Private Internet Access VPN service. This tutorial is known to work on
Things to do
- Enable SSH on OSMC. SSH can be installed from The APP store in MyOSMC. The good thing is OpenVPN is already installed by default.
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 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
- Okay, now we start! It’s always a good idea to have your OSMC up-to-date.
sudo apt-get update
sudo apt-get dist-upgrade
- 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 https://www.privateinternetaccess.com/openvpn/openvpn.zip
sudo unzip openvpn.zip
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 mv UK\ London.ovpn /etc/openvpn/UK_London.ovpn
Let’s make our first connection to the VPN to make sure everything is working. I’m going to use the server in Sweden with the following command.
sudo openvpn ./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 http://ipecho.net/plain -O – -q ; echo
- or
curl ipinfo.io/ip

- Now it automatically connects to your VPN on boot up of your system. I hope you find this tutorial helpful
- I would like to thank Tom Doyle
for getting me up to speed on some of the changes so there won’tbe conflicting issues setting up your VPN. He also gave us a solution for DNS leaks thank you, Tom for the help!
Prevent DNS leaks
To prevent DNS leaks this can be done as follows
sudo apt-get install openresolv
- Add the following to the bottom of pia_sweden.conf:
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf
sudo nano /etc/openvpn/pia_sweden.conf

- Note the best place for help is https://discourse.osmc.tv
- Say hi to me neurosisone
This tutorial was originally posted on backtrails.net. I own both sides and moving everything to underscorenews.net. Tutorial originally published on Apr 30, 2017.
Bruce
I spent days trying to do this, then I found your instructions, it all went smooth a silk after that. Thank you very much
Thank you, Chris! I’m glad it helped.
Great great! helped a lot.
Now I am trying to combine it with Pi-Hole but this I hope will somehow work.
Thank you!