How to setup TorGuard OpenVPN On Raspberry Pi

In this tutorial, we will show you how to connect your raspberry pi to your TorGuard VPN.

This tutorial was written and verified on Rasbian V7.6 (wheezy)

Step 1.

The first thing we need to do is to log into our raspberry pi, you can ssh into the pi from the command line if you are using Linux of a mac. If you are using a PC you can download PuTTY ( The default login is: pi and the password is: raspberry

Step 2.

The next thing that we are going to do is update the package list by typing into the command line.

sudo apt-get update

Step 3.

We are now going to download and install OpenVPN, the software that we will use to connect to TorGuard.

sudo apt-get install openvpn

Step 4.

Now we are going to download the necessary configuration files for OpenVPN type:

cd /etc/openvpn
sudo wget
sudo unzip -j
sudo chmod 777 update-resolv-conf

Step 5.

Next, we need to add a single line to each of the configuration files that we have just unpacked. The sed command will allow us to modify all of the files at once. Type:

sudo sed -i '/auth-user-pass/cauth-user-pass user.txt' *.ovpn

Step 6.

Now we need to create the file we just referenced to store our login and password information to the VPN/ Type:

sudo nano user.txt

In this file create only two lines of text (replace username with your tg VPN username and likewise with the password)


press crtl+x to save the file then press y and enter.

Step 7.

Since the file, we have created contains sensitive info we need to ensure that only the user that created the file can read and write to it. Type:

sudo chmod go-rwx user.txt

Step 8.

To establish a connection now we type(or cut and paste):

cd /etc/openvpn/
mv  TorGuard.Canada.Toronto.ovpn  TorGuard.Canada.Toronto.conf
sudo openvpn TorGuard.Canada.Toronto.conf

Step 9.

Now we need to verify that everything is working properly. Type:


you should see three entries scroll up



tun0 ? this is the one that will indicate the VPN tunnel is active if it's not there then something is not right.

Step 10.

Now we will verify that our public IP address is masked. Open up a browser window in your computer (Assuming that it is not connected to a VPN or proxy) google what is my IP and your public IP address will be displayed. Now in the terminal connection of your pi type:

curl -s|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

If the IP address that is returned is different from the IP address in your browser then everything is working.

Step 11.

This is all well and good, but it would be even better if the pi would establish the connection to the VPN as soon as it boots up. An easy way to do this is to make a crontab. Type:

crontab -e

add the line

@reboot sudo openvpn --daemon --cd /etc/openvpn --config TorGuard.Canada.conf

to test this type:

sudo reboot

Wait a few minutes and when you can log back in re-run the tests.


Should you even want to disconnect from the VPN just type:

killall -9 openvpn


Was this answer helpful? 30 Users Found This Useful (155 Votes)