A virtual private network, or VPN, is a vital part of online privacy and security. In short, if you're not already running one alongside your usual security tools, you should be. VPNs are available for Windows, Linux, and macOS, as well as Android and iOS.
But what if you're using a Raspberry Pi?

Most operating systems for the Pi are based on Linux; unfortunately, VPN providers don't offer dedicated Pi software. If you need to set up a VPN for your Pi, perhaps to avoid some region-blocking in Kodi, then you'll need to do some manual configuration.
We're going to look at how to set this up. The following steps will work with all Debian-based distros, such as Raspbian Jessie, and the Kodi distros (like OpenElec and OSMC).
Why Use a VPN?
There are many good reasons to use a VPN, all of which eventually come down to user privacy. In short, a VPN client encrypts data from your PC or mobile and sends it via a VPN server. From this anonymous point, your online activity is hidden.
How might this be useful? Well, if you're using your Raspberry Pi as a desktop computer and you're based in a region where online censorship is rife, a VPN can help circumnavigate such restrictions. The same technology can help even if you just want to download software for your Pi while living under an oppressive regime.

For a Kodi media center, a VPN might circumvent region-blocking, censorship, or anything else blocking your access to media.
For instance, if you wanted to access BBC iPlayer from the U.S. (and if you're a traveling British citizen, there's no reason why you shouldn't), a VPN can help. By connecting to a VPN in the U.K., you'll be able to stream your favorite TV show (Doctor Who, perhaps). You should be confident that it is legal to enjoy your media center in the way you have planned, however.
My guide, 10 Reasons Why You Should Be Using a VPN, should explain more. Meanwhile, if you want more of a background on the encryption, security, and how a VPN works, check our VPN primer.
As noted, there are also other ways to use a VPN. You might like to run a VPN on your desktop computer, for instance, or set up some universal defense by setting up a VPN account on your router.
Either way, you should be using one.
How to Choose a VPN
If you're simply browsing the web and wish to do so in privacy, then a standard VPN (albeit one offering minimal logs) should be chosen.
However, if you wish to beat region blocking or use a streaming add-on in Kodi, then you need to find a VPN that will offers unlimited bandwidth for video streaming. It will also need to be peer-to-peer-friendly, as many add-ons use P2P networking for streaming content.
Just make sure you're using a VPN service that is trustworthy.
Requirements for a VPN on the Raspberry Pi
To use a VPN on a Raspberry Pi, you will need the following things:

- Raspberry Pi 2 or later. Earlier models will struggle with the encryption.
- VPN account that supports OpenVPN. Our favorite is ExpressVPN, but others are available.
- A paid VPN account is preferable if you are streaming video.
- Free VPNs are also available but less suitable for streaming.
- SSH software on your PC.
- Windows users should use PuTTY.
- Linux and Mac have SSH functionality natively via the terminal.
- SSH needs to be enabled on the Pi. One way is to hook it up to a monitor and change the default SSH setting in raspi-config. If you're not able to do this, insert the Pi's microSD card into your PC, browse to the boot directory, and create a blank text file called SSH (no file extension). After you've safely removed the disk, replace it into your Pi and boot up. SSH will then be enabled.
OpenVPN is an open-source VPN application that enables you to use the configurations provided by VPN services using OpenSSL for encryption. In short, you can set up a VPN on a Raspberry Pi without a dedicated app.
You have two options for setting up a VPN. The first is to install OpenVPN within Raspbian (or your chosen Raspberry Pi OS). Alternatively, you can set up a VPN within your preferred Kodi image.
Set Up a VPN on Your Raspberry Pi
With various images available for the Pi, this can get a little fiddly.
Fortunately, as long as you're using a Debian-based image, this solution will work. It doesn't matter whether you're using Kodi or not. This is a straightforward method for running a VPN on your Raspberry Pi regardless of operating system or disk image.
We've tried this out using the OSMC flavor of Kodi, which, like Raspbian, is based on Debian. However, it should also work on OpenElec.

Begin by connecting to your Raspberry Pi via SSH, using the correct credentials for your media center image, and installing openVPN:
sudo apt-get install openvpn
Once complete, issue the reboot command:
sudo reboot
When your Pi has restarted, you'll need to download the openVPN files from your VPN provider. The overwhelming majority of services offer support for openVPN.

The most expedient way to do this is download the files to your PC, extract them (they're typically ZIP files), and then send them to your Raspberry Pi via SFTP. Create a new folder for their destination, called openvpn-config. This should be within /home/.
Once these files are copied, use SSH to issue the run command:
sudo openvpn your_ovpn_configuration_file.ovpn
You'll be prompted for your VPN username and password, so enter these.

Within moments, the VPN connection should be established, and you'll be enjoying a fully private Raspberry Pi Kodi experience. You're ready to go region-free!
Note that if you're running Kodi on a different device or platform, you should be able to install a VPN via a dedicated add-on.
Disconnecting and Changing the VPN
Should you wish to disconnect the VPN, you'll need to hit Ctrl + C to end the session. To connect to a different server, simply repeat the earlier command, but with a different configuration file. Each connection will require a username and password.
If you're using the VPN with Kodi, you'll need to leave it running. As a result, it might be useful to set up an SSH or VNC connection via an app on your mobile device and use this to monitor the VPN. Should the connection drop, for example, you'll need access to re-enable it. If you're using a Kodi remote app, it makes sense to have your remote access all in one place!
Do you need to use a VPN with your Raspberry Pi? Perhaps you already use one? Tell us how it worked out for you.