Private Internet Access (PIA) provides high quality and inexpensive VPN services, but installing VPN routes on linux can be tedious or require the installation of third party applets. The purpose of this repository is to host and maintain a configuration package that will automatically populate NetworkManager keyfiles for use with PIA OpenVPN service on various Linux distributions and to avoid the installation of any third party applets.
Install with pip install pypia
On first run, start with pypia -i
.
The pypia
package has been designed to automatically detect your operating system. Currently the supported distros are:
- Fedora
- Manjaro
- Ubuntu (various flavors, e.g. Lubuntu, should also work)
- Elementary OS
- Antergos
- Linuxmint
- openSUSE
- Kali
- Arch
- Solus
- CentOS
*For other distros, please see note at end of this README
-
System
- Python 3. This script is written in Python 3. Python 2 is not supported.
- network manager
- openvpn
The script installs the network-manager-openvpn package (name of package may be different depending on your distribution).
-
General
- PIA subscription (which is a pay service).
PIA certificate, which is automatically downloaded by the script, is provided by PIA here. Route/VPN server information is downloaded from this page.
- You can use pip to install this module:
pip install pypia
Note: in some distrospip
points to python2. In those distros, it may be required to usepip3
orpython3 -m pip
instead of plainpip
. In some cases, pip installs packages to a user path. It may be required to addPATH=$PATH:~/.local/bin
to your~/.bashrc
file to be able to invokepypia
directly from the command line. - Once installed via
pip
, you should dopypia -i
to initialize, which will configure the NetworkManager keyfiles. Root permissions are required to install dependencies via the package manager and to write the VPN config files to/etc/NetworkManager/system-connections/
, so you will be prompted to enter the root password.
If you can't or don't want to use pip, alternatively you can clone this repository and runpython3 pypia/pypia.py -i
to configure the keyfiles. - At some point in the installation process you will be prompted for your PIA-issued user ID (typically starts with a "p" and is followed by a bunch of numbers). You will also be prompted for your password, which is simply saved to the config files (in plain text, but only root user can view/edit those files).
If everything goes as intended, the VPN routes will be accessible from the VPN Connections menu in the NetworkManager applet or via the nmcli
command line tool.
usage: pypia [-h] [-i] [-p] [-s] [-r {us,all,int}] [-f] [-d]
optional arguments:
-h, --help show this help message and exit
-i, --initialize configure pia vpn routes as networkmanager keyfiles.
requires sudo priveleges. use this flag on first run
and anytime you want to refresh pia vpn routes
-p, --ping ping each vpn server and list latencies
-s, --shuffle connect to or shuffle a random vpn
-r {us,all,int}, --region {us,all,int}
"us" for US only, "int" for non-US, "all" for
worldwide
-f, --fastest connect to network with lowest ping latency
-d, --disconnect disconnect current PIA vpn connection
If your distribution of choice is not currently listed as supported, please take a minute to help me add support! To add it, I'll need to know:
- The specific name of the
network-manager-openvpn
package in your particular package manager. Usually searching the package database for "openvpn" is enough to find it. - The install command for your package manager (e.g.
apt install
ordnf install
, etc.) - At a python (3+) prompt, enter the following commands and let me know what the string returned from the
get_distro()
function is:
import subprocess
def get_distro():
os_release = subprocess.check_output(['cat', '/etc/os-release']).decode('utf-8').splitlines()
os_dict = {i.split('=')[0]: i.split('=')[1].strip('"') for i in os_release if '=' in i}
distro = os_dict['ID'].lower()
return distro
get_distro()
With that information, I can update the package_info.json
file to include your distro. Or feel free to submit a pull request.
The python code in this project is distributed under GPLv3.
If you want to sign up for PIA, feel free to use my affiliate link. If you'd rather not use that link, no worries! This is free software that I hope you continue to use and enjoy.