This page looks best with JavaScript enabled

Setup an always on VPN in Ubuntu

 ·  ☕ 2 min read  ·  ✍️ Chris Titus

This is a guide on how to set up an always on VPN in Ubuntu, and basic troubleshooting of VPNs in ubuntu server. I used Private Internet Access as an example VPN connection.

Use my affiliate link to get a Private Internet Access VPN: This is a must-have for a dedicated Linux box specifically for privacy concerns.

Setup VPN in Ubuntu – No Commentary

Setup VPN no commentary
Note: YouTube Video - Hold Ctrl + Left Click to open in new window

Setup VPN in Ubuntu – With Commentary

Setup VPN in Ubuntu with commentary
Note: YouTube Video - Hold Ctrl + Left Click to open in new window

VPN setup commands:

sudo su
apt-get install openvpn -y
cd /etc/openvpn
nano .secrets

p1234567 ###PASTE YOUR INFO###

chmod 600 .secrets
mv 'US Texas.ovpn' texas.conf
nano texas.conf

auth-user-pass .secrets ###CHANGE THIS LINE###

systemctl start openvpn@texas
systemctl status openvpn@texas
nano /etc/default/openvpn ###UNCOMMENT AUTOSTART

Diagnostic Commands

Once complete, find the external IP as that is needed to make sure it is working. If your VPN is failing to connect I recommend using tail on the syslog so consequently, you can find any issues that are stopping the connection.

Extra Tools

Find External IP: dig TXT +short | awk -F’"’ ‘{ print $2}’
Debug as necessary: tail -f /var/log/syslog|grep ovpn`

In closing, make sure you always use a VPN when you are concerned about your privacy. I’ve also set these up on Linux boxes between offices and it makes for a great inexpensive site-to-site VPN. Therefore, you don’t have to spend tons of money on proprietary gateways that go out of date in a couple years.

I live stream on Twitch and encourage you to drop in and ask a question. I regularly publish on YouTube and, but if you need immediate assistance, check out the Terminal Cafe with Discord Invite Link.

Share on

Chris Titus
Chris Titus
Tech Content Creator