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.

Chris Titus Tech


Exclusive Content

  • Members Section (CC Only)
    • Digital Downloads with Guides and Pre-Built Images
    • Monthly Members Only Video
    • $5 Per Month (100% of Proceeds goes to Chris Titus Tech)
  • YouTube Chris Titus Tech Membership (All Payments Accepted)
    • Monthly Members Only Video
    • YouTube Emojis for Comments and Live Chat
    • YouTube Badges that changes based on membership time for comments and chat.
    • All YouTube comments are highlighted when I review comments daily.
    • $4.99 Per Month (70% of the Proceeds goes to Chris Titus Tech)

Chris Titus
Chris Titus
Tech Content Creator