Autostart OpenVPN using systemd in Linux

Step 1: In the /etc/openvpn folder, create a text file called pass:

# sudo nano /etc/openvpn/pass

Step 2: and enter your LimeVPN Account ID (usually your email address) on the first line and any non-blank text on the 2nd line, then press ‘Ctrl X’ to save the changes and exit the text editor.

(Optional) Change the permissions on the pass file to protect the credentials:

 # sudo chmod 400 /etc/openvpn/pass

Step 3: Rename the .ovpn file to ‘client.conf’:

 # sudo cp /etc/openvpn/Germany.ovpn /etc/openvpn/client.conf

Step 4: On Ubuntu 16.04 LTS, OpenVPN installs and initiates a service by default. If you are using Ubuntu 16.04 LTS. For Ubuntu 18.04 LTS and up, enable the OpenVPN service to run while booting:

# sudo systemctl enable [email protected]

Step 5: Reload the daemons:

# sudo systemctl daemon-reload

Step 6: Start the OpenVPN service:

# sudo service [email protected] start

Step 7: Reboot and test if it is working by checking the external IP:

# curl

Step 8: If curl is not installed:

# sudo apt install curl
Did this answer your question?