Mike Body Caricature Mike Head Caricature

Ramblings of a Madman

General Ramblings About all things JavaScript and Firefox Developer Tools

Installing VPN from the Linux Command Line

To stop people snooping on what we are doing on the internet or when restrictive governments prevent people from accessing popular websites you can use a VPN to protect your privacy and allow you to access the internet without restrictions.

Most VPN providers provide simple step-by-step instructions to get VPN set up on most operating systems but many fail to give instructions about how to autostart a VPN in a non graphical environment.

The following will work with the files provided by most VPN providers with a couple of small changes:

Of course, the url that your provider uses may be different:

# Get the Files from your Provider
$ cd /tmp
$ wget https://www.privateinternetaccess.com/openvpn/openvpn.zip
$ unzip openvpn.zip

# Copy Certificates to /etc/openvpn
$ cp ca.crt /etc/openvpn/
$ cp crl.pem /etc/openvpn/

# Enable Autologin
$ nano /etc/openvpn/login.conf

# Edit file to contain your username and password on the first two lines:

<ctrl><x> to exit and Y to save.

$ chmod 400 /etc/openvpn/login.conf

# Point OpenVPN Towards the Right Files. The .ovpn files may
# not be by country so substitute them as appropriate.
$ nano Country.ovpn

# Edit the file to prefix the pem and crt paths with:

# Change the auth-user-pass line to read:
auth-user-pass /etc/openvpn/login.conf

<ctrl><x> to exit and Y to save.

$ cp Country.ovpn /etc/openvpn/Country.conf

# Autostart the VPN. "Country" is the name of your .conf file without
# any extension so in my case Country.conf (see the previous steps).
$ nano /etc/default/openvpn

# Edit the file so it contains:

# Check that Autostart is Working
$ reboot
Installing VPN from the Linux command line

To check if the VPN is running open lynx and go to google.com. It should take you to the specific countries site.

That is it, you are done!

Mike Ratcliffe

Mozilla developer.