intelekt
Posts: 8
Joined: Sat Mar 07, 2020 3:22 pm

Starting OpenVPN at startup, on Raspbian Buster

Sat Mar 07, 2020 3:35 pm

Hi, :D

Im trying to get my surfshark vpn to run at startup so i don't have to constantly type in the run command and then the enormous username and password credentials in terminal.

Forgive me if this question has been asked a thousand times before, but i just can't find any info that isn't very technical or assumes i already know the basics of linux!

I need the answer to be dumbed down so a simpleton like me can get an understanding of it.


Right now when i start Raspbian Buster i have to do this in terminal: :shock:

Navigate to OpenVPN directory by entering:
cd /etc/openvpn
To see the list of all the available servers enter:
ls
Choose one of the servers for the serve list and connect to Surfshark by entering:
sudo openvpn [file name]
For example:
sudo openvpn us-dal.prod.surfshark.com_udp.ovpn
sudo openvpn /etc/openvpn/us-dal.prod.surfshark.com_udp.ovpn
And connect with the surfshark credentials.

Help, :roll:

Thanks
Ade

intelekt
Posts: 8
Joined: Sat Mar 07, 2020 3:22 pm

Re: Starting OpenVPN at startup, on Raspbian Buster

Sun Mar 08, 2020 3:35 pm

Anyone :!: Pretty Please ;)

User avatar
default_user8
Posts: 680
Joined: Mon Nov 18, 2013 3:11 am

Re: Starting OpenVPN at startup, on Raspbian Buster

Mon Mar 09, 2020 5:44 am

Why aren't you using pivpn?

https://www.pivpn.io
Two heads are better than one, unless one's a goat head.

torak666
Posts: 57
Joined: Tue Feb 06, 2018 4:58 pm

Re: Starting OpenVPN at startup, on Raspbian Buster

Mon Mar 09, 2020 10:39 am

You can try to use command crontab -e and call an automatic script to do your job after the reboot is done
https://www.raspberrypi.org/documentati ... ge/cron.md

intelekt
Posts: 8
Joined: Sat Mar 07, 2020 3:22 pm

Re: Starting OpenVPN at startup, on Raspbian Buster

Mon Mar 09, 2020 12:35 pm

I thought PiVPN was to turn the actual Pi into a vpn!

User avatar
DougieLawson
Posts: 40787
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Starting OpenVPN at startup, on Raspbian Buster

Mon Mar 09, 2020 12:53 pm

To get any OpenVPN configuration running at boot time you need to start by creating /etc/openvpn/foobarBletch.conf

Something like

Code: Select all

client
dev tun
proto udp
remote openvpn.server.example.com 1194 # can use a dotted decimal address
resolv-retry infinite
nobind
persist-key
persist-tun
ca openvpn.server.ca.crt
cert foobarBletch.client.crt
key foobarBletch.client.key
remote-cert-tls server
comp-lzo
verb 3
Obviously the certs and key need to be in the /etc/openvpn or you can embed them in the config file with

Code: Select all

client
dev tun
proto udp
remote openvpn.server.example.com 1194 # can use a dotted decimal address
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
comp-lzo
verb 3
<ca>
-----BEGIN CERTIFICATE-----
MIIFR...
*** cert authority certificate redacted ***
-----END CERTIFICATE-----
</ca>
<cert>
-----BEGIN CERTIFICATE-----
MIIFl...
*** client certificate redacted ***
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN PRIVATE KEY-----
MIIEv...
*** client key redacted ***
-----END PRIVATE KEY-----
</key>
You then enable OpenVPN at boot time with
sudo systemctl enable openvpn
sudo systemctl enable openvpn@foobarBletch
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
default_user8
Posts: 680
Joined: Mon Nov 18, 2013 3:11 am

Re: Starting OpenVPN at startup, on Raspbian Buster

Mon Mar 09, 2020 11:55 pm

intelekt wrote:
Mon Mar 09, 2020 12:35 pm
I thought PiVPN was to turn the actual Pi into a vpn!
Technically it does, but it's still Raspbian. You can install other programs, I run pivpn, and pihole on mine. I don't remember which one i started with, but I started with a minimal raspbian install, and ran the pivpn, and pihole scripts to install both programs.
Two heads are better than one, unless one's a goat head.

Return to “Beginners”