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:

Get the Files from your Provider

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

$ 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
$ vi /etc/openvpn/login.conf

The file should contain the following:

your-privateinternetaccess-username  
your-privateinternetaccess-password  
$ 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.

$ vi Country.ovpn

Prefix the pem and crt paths with /etc/openvpn/

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

$ cp Country.ovpn /etc/openvpn/Country.conf
Autostart the VPN

"Country" is the name of your .conf file without and extension so in my case Country.conf (see the previous steps).

$ vi /etc/default/openvpn

Add AUTOSTART="Country"

Check that Autostart is Working
$ reboot

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!

comments powered by Disqus