/sc_assets/441/logo.png

Linux - Autostart OpenVPN in systemd (Ubuntu)

Last updated by Shayne M on April 26, 2020 12:47

Linux - Autostart OpenVPN in systemd (Ubuntu)

In order to configure OpenVPN to autostart for systemd, complete the following steps:

  1. 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.

  2. 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/
  3. 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.

  4. 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.

  5. (Optional) Please change the permissions on the pass file to protect the credentials from other users:
    # sudo chmod 400 /etc/openvpn/pass
  6. 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
  7. 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]
  8. Reload the daemons:
    # sudo systemctl daemon-reload
  9. Start the OpenVPN service:
    # sudo service openvpn@client start
  10. 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