I had too google like crazy to find a solution on how to start OpenVPN on reboot and use both a .ovpn file supplied by my VPN provider, and the login credentials. Hopefully this can help you too.
First off. Install OpenVPN on ubuntu/linux from the CLI / command line. I won’t give instructions on that since there’s already a few million tutorials out there.
Download your .ovpn file from your VPN provider. Usually you can choose different ones depending on what server location you want to spoof as.
Upload the .ovpn-file to /etc/openvpn/*.ovpn with the following command, your SSH user and pass is needed to connect to your server (unless you are doing it all directly on your server).
$ scp /local/file ssh_user@host:/etc/openvpn/YOURFILENAME.ovpn
Create a new credentials file to hold your VPN username and password
$ sudo nano /etc/openvpn/pass.txt
Add two lines in the file, the first with only your username and the other with your password
Save and close
Now copy your settings file and rename it
$ sudo cp /etc/openvpn/*.ovpn /etc/openvpn/*.conf
This turns your .ovpn into a bootable configuration file. Now open the newly created config file.
$ sudo nano /etc/openvpn/*.conf
Change the line “auth-user-pass” into “auth-user-pass pass.txt” and then save and close.
Now we need to tell OpenVPN to automatically load any .conf files on boot.
$ sudo nano /etc/default/openvpn
Uncomment (by removing the # in front of) the line: AUTOSTART=”all” and save the file.
Now we only need to tell Ubuntu to start the OpenVPN service on startup…
$ systemctl enable openvpn
That is all! Reboot your system. After a few minutes when all is up and running, you can check the public IP of your server.
$ dig +short myip.opendns.com @resolver1.opendns.com
This will return an IP. You can visit a site lite infosniper.net and input that IP to see which geographical location the IP has. Hopefully it wont point to your own ISP anymore, but to a server run by your VPN-provider on the location choosen.