Install OpenVPN for Raspberry Pi OS
This guide was created for Raspberry Pi OS Buster Lite but also works to set up an OpenVPN client on Raspberry Pi OS Buster with desktop. This setup has not yet been tested on Raspberry Pi OS Bullseye.
What can OpenVPN be used for?
OpenVPN is an open source connection protocol used to facilitate a secure tunnel between two points in a network. In layman’s terms, this means that it is a trusted technology used by many virtual private networks, or VPNs, to make sure any data sent over the internet is encrypted and private.
1. Update the Raspberry Pi
sudo apt-get update
sudo apt-get upgrade
2. Install OpenVPN
sudo apt-get install openvpn unzip
3. Make sure the time zone is correct
Run the command below and go through the configuration prompt to select the correct time zone.
sudo dpkg-reconfigure tzdata
4. Choose region you want to connect to
Add-on service
5. Elevate your privileges to root
sudo -i
6. Download configuration file & setup OpenVPN
cd /tmp && wget https://files.ovpn.com/raspbian/ovpn-se-gothenburg.zip && unzip ovpn-se-gothenburg.zip && mkdir -p /etc/openvpn && mv config/* /etc/openvpn && chmod +x /etc/openvpn/update-resolv-conf && rm -rf config && rm -f ovpn-se-gothenburg.zip
7. Enter your login credentials
echo "CHANGE TO YOUR USERNAME" >> /etc/openvpn/credentials
echo "CHANGE TO YOUR PASSWORD" >> /etc/openvpn/credentials
8. Start OpenVPN and see that everything works
sudo openvpn --config /etc/openvpn/ovpn.conf --daemon
9. Verify that the connection was successful
Wait for about a minute after running the last command, then run:
curl https://www.ovpn.com/v2/api/client/ptr | python -m json.tool
You should see something like:
{"status":true,"ip":"46.227.67.132","ptr":"cliXXX.ovpn.com"}
10. Done
Congratulations! Now your Raspberry Pi will run behind OVPN. The Raspberry Pi will connect automatically when it is started.
Read More: https://www.ovpn.com/en/guides/raspberry-pi-raspbian