Skip to content

Instantly share code, notes, and snippets.

@mtparet
Forked from darK-Zi0n-te4am-cr3vv/etc..init..openvpn-instance.conf
Last active December 29, 2015 11:03
Show Gist options
  • Save mtparet/b9d1e34927362d300b67 to your computer and use it in GitHub Desktop.
Save mtparet/b9d1e34927362d300b67 to your computer and use it in GitHub Desktop.
Starting OpenVPN using Systemd

As root:

Copy your config file .ovpn to /etc/openvpn/config.ovpn

Add a file /etc/openvpn/auth.txt with two lines:

your_username
your_password

Remove all permission on it and add it back only read for root:

chmod a-rwx /etc/openvpn/auth.txt
chmod ug+r /etc/openvpn/auth.txt

Copy the systemd service to your system and enable it systemctl enable myopenvpn.service

[Unit]
Description=Job that runs the openVpn
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=forking
ExecStart=/usr/sbin/openvpn --config /etc/openvpn/config.ovpn --auth-user-pass /etc/openvpn/auth.txt
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment