Here is how I got it working. In my folder with all my vpn ovpn files I create a file called auth.txt
. Which contained the following, substituted for my actual credentials:
Username
Password
I then opened up the ovpn file I wanted to use, and found the line with auth-user-pass
I modifying it to look like this, replace path with full path of your auth.txt file:
auth-user-pass /home/philip/open_vpn/auth.txt
I then made a bash script called start_vpn.sh
which looks like:
#!/usr/bin/env bash
sudo openvpn --config /home/philip/open_vpn/nord/ca24.nordvpn.com.udp1194.ovpn
I then create a systemd startup script at /etc/systemd/system/start-openvpn.service
which looks like:
[Service]
ExecStart=/home/philip/open_vpn/start_vpn.sh
[Install]
WantedBy=default.target
I then enable the systemd job with:
systemctl enable start-openvpn.service
Bonus:
If you have 100s of ovpn files like me you may want to update the line in all these files at once. Here is the sed
command I used in the folder with my ovpn file, you will nedd to update to reflect your system:
sed -i *nordvpn* -e 's/auth-user-pass/auth-user-pass \/home\/philip\/open_vpn\/auth.txt/g'