Linux - Autostart OpenVPN in systemd (Ubuntu)
Last updated by Shayne M on April 25, 2020 22:47
Linux - Autostart OpenVPN in systemd (Ubuntu)
In order to configure OpenVPN to autostart for systemd, complete the following steps:
- Run the command:
# sudo nano /etc/default/openvpn
and uncomment, or remove, the "#" in front of
AUTOSTART="all"
then press 'Ctrl X' to save the changes and exit the text editor.
- Move the .ovpn file with the desired server location to the '/etc/openvpn' folder - replace /home/download/ with the location where you download the .ovpn files from https://www.vpnsecure.me/members
# sudo cp /home/download /etc/openvpn/
- Edit the .ovpn file you copied in the previous step and add the line askpass /etc/openvpn/pass
# sudo nano /etc/openvpn/us5-username.ovpn
then press 'Ctrl X' to save the changes and exit the text editor.
- In the '/etc/openvpn' folder, create a text file called pass:
# sudo nano /etc/openvpn/pass
and enter your VPNSecure Password on the first line, then press 'Ctrl X' to save the changes and exit the text editor.
- (Optional) Please change the permissions on the pass file to protect the credentials from other users:
# sudo chmod 400 /etc/openvpn/pass
- Rename the .ovpn file to 'client.conf' in order for systemd to start openvpn automatically:
# sudo cp /etc/openvpn/us5-username.ovpn /etc/openvpn/client.conf
- Ubuntu 16.04, OpenVPN installs and initiates a service by default. If you are using Ubuntu 16.04, skip to step 10.
For Ubuntu 18.04 LTS+ enable the OpenVPN service to autorun when booting:
# sudo systemctl enable [email protected]
- Reload the daemons:
# sudo systemctl daemon-reload
- Start the OpenVPN service:
# sudo service openvpn@client start
- Reboot and test if it is working by checking the external IP:
# curl ipinfo.io
If curl is not installed:
# sudo apt install curl
VPNSecure Provides Secure VPN servers in over 45+ Countries
If you are a looking for a versatile easy to use VPN service, checkout Today