How to set up a VPN (Private Internet Access) in Raspberry Pi

In this ./note I am going to show you how set up the VPN connection provided by Private Internet Access in Raspberry PI (but the same steps are valid for any other Linux distribution).

I found these instruction in the Private Internet Access forum (

1. If you don’t have done this already, you need to install OpenVPN.

sudo apt-get install openvpn

2. Move to the OpenVPN directory in /ect:

cd /etc/openvpn

3. Download from the Private Internet Access website the zip folder. This folder contains all the config files for OpenVPN.


4. Unzip the folder using unzip. If you don’t have unzip already installed in your system run the following command:

sudo apt-get install unzip

and then unzip:

sudo unzip

5. In order to see the list of servers to which you can connect run:

ls -l

6. As you can see each server config file has .ovpn extension. Now you can run the final command to connect to the server:

sudo openvpn config-sever-filename.ovpn

Once the previous command is executed you are required to insert your username and password of your Private Internet Access account. If you want to avoid to insert username and password every  time you want to connect to the VPN you can follow these steps:

1. Create a .txt file in the /etc/openvpn folder (same folder of the .ovpn file) . You can name this file ‘pass.txt
2. In the first two lines of the file put your username and password, like:



3. Save and close the file.
4. Open up your .ovpn and add the following line at the bottom:

auth-user-pass pass.txt

5. Save and try to connect again. You should not be required to insert username and password this time.

That’s it.

In a next post I will show how to connect automatically to the VPN at boot.