Skip to content

Instantly share code, notes, and snippets.

@gwsales
Last active February 16, 2019 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwsales/0e18ba93b567d219274ddfd69311665c to your computer and use it in GitHub Desktop.
Save gwsales/0e18ba93b567d219274ddfd69311665c to your computer and use it in GitHub Desktop.
Private Internet Access PPTP VPN Profile Script
#!/bin/bash
## This script requires jq
if ! [ -x "$(command -v jq)" ]; then
echo 'Error: jq is not installed.' >&2
exit 1
fi
echo -n "PIA pptp username (xNNNNNNN not pNNNNNNN): "
read pia_username
if [ -z "$pia_username" ]; then
error "Username is required, aborting."
fi
echo -n "PIA pptp password: "
read pia_password
if [ -z "$pia_password" ]; then
error "Password is required, aborting."
fi
servers_json=$(curl -Ss "https://www.privateinternetaccess.com/vpninfo/servers?version=24" | head -1| jq -S 'del(.info)')
servers=(`echo $servers_json | jq -S '.[].dns'`)
for i in "${servers[@]}"
do
gateway=$(echo $i | sed 's/"//g')
name="pia-$(echo $gateway | cut -d . -f1)"
echo "Creating $name with gateway of $gateway"
## Create nmcli VPN profile
sudo nmcli con add type vpn ifname '*' vpn-type pptp -- connection.id $name connection.autoconnect no ipv6.method ignore vpn.secrets "password = $pia_password" vpn.data "password-flags = 0, user = $pia_username, require-mppe = yes, gateway = $gateway"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment