Centos 7 OpenVPN + PIA

Centos 7 OpenVPN + PIA

Last updated 14th feb 2019

Packages to install

Firstly install the latest updates to your machine.

yum update -y

Then we need to install the epel repository.

yum install epel-release -y

And then the final tools we’ll need for general setup and to run PIA.

yum install openvpn unzip curl wget -y

Configuration

Now on to the fun part firstly navigate to the openvpn directory.

cd /etc/openvpn

Use wget to download the zip file that contains all the vpn configuations for each PIA location.

wget https://www.privateinternetaccess.com/openvpn/openvpn.zip

Use unzip to extract the .opvpn files to the directory.

unzip openvpn.zip

Create a credentials file for your PIA logins with your favourite text editor (mines nano) default is vi.

nano cred.conf

Place your PIA credentials in the file like this.

[username]                                                                                                                                     [password]

If you are also using nano press CTRL+x and then Y to save and quit. Then we need to change the permissions on the file.

chown root:root cred.conf
chmod 400 cred.conf 

Create a symlink for the config file you want to use

ln -s /etc/openvpn/[PIA-server].ovpn server.conf

Open the config file

nano [PIA-server].ovpn 

add/edit the line auth-user-pass to auth-user-pass cred.conf

On my server, I have SELinux set to permissive which means it logs what it would normally block if you would like to do the same edit the se config file /etc/selinux/config to show permissive in the line selinux.

Alternatively run the command

restorecon -Rv /etc/openvpn/

Enable openvpn at boot.

systemctl enable openvpn@server

Start Openvpn Warning this may close your ssh session.

systemctl start openvpn@server

Check to see if its worked.

curl ipecho.net/plain ; echo

If its different it worked now reboot and see if starts on boot as expected.

reboot now

Run the curl command again

curl ipecho.net/plain ; echo 

If its still different you have now successfully set the box to connect to your PIA VPN on boot

Tags: , ,

Leave a Reply

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