Debian – Setting Up OpenVPN Client Systemd Service

debianopenvpnsystemd

Just installed openvpn on Debian 9 looking for the right way to enable client at boot:

apt install openvpn

This won't work:

Error opening configuration file: /etc/openvpn/myclient

:

nano /etc/openvpn/client/myclient.ovpn
systemctl status openvpn-client@myclient
systemctl start openvpn-client@myclient


giu 10 11:23:11 gigi openvpn[15284]: Options error: In [CMD-LINE]:1: Error opening configuration file: myclient.conf
giu 10 11:23:11 gigi openvpn[15284]: Use --help for more information.
giu 10 11:23:11 gigi systemd[1]: openvpn-client@myclient.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd

Insteda with the configuration file name will work:

nano /etc/openvpn/client/myclient.conf 
systemctl start openvpn-client@myclient

but with "-" within the conf name it will fail.

This will work:

nano /etc/openvpn/client/myclient.conf
systemctl status openvpn@myclient
systemctl enable openvpn@myclient

● openvpn@myclient.service - OpenVPN tunnel for myclient
   Loaded: loaded (/lib/systemd/system/openvpn-client@.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

Didn't find any documentation about it to see if should work in one way or the other.

Which way should be preferred openvpn/client/conf or openvpn/conf?

Best Answer

With the ".conf" file it is working: /etc/openvpn/client/myclient.conf. It was the folder path that was wrong!