[Unit] Description=OpenVPN authenticator (%i) Documentation=https://github.com/jkroepke/openvpn-auth-oauth2 ConditionPathExists=/etc/openvpn-auth-oauth2/%i.yaml Requires=network-online.target Wants=network-online.target nss-lookup.target openvpn.service After=network-online.target nss-lookup.target basic.target openvpn.service openvpn@.service openvpn-server@.service PartOf=openvpn.service openvpn@.service openvpn-server@.service StartLimitIntervalSec=30 StartLimitBurst=3 [Service] Restart=on-failure RestartSec=30 # Run as an unprivileged user with random user id. DynamicUser=true User=openvpn-auth-oauth2-dynamic Group=openvpn-auth-oauth2-dynamic SupplementaryGroups=openvpn-auth-oauth2 ssl-cert ExecStart=/usr/bin/openvpn-auth-oauth2 --config /etc/openvpn-auth-oauth2/%i.yaml NoExecPaths=/ ExecPaths=/usr/bin /usr/lib /lib ExecReload=/usr/bin/env kill -USR1 $MAINPID #LoadCredential=openvpn-auth-oauth2:/etc/openvpn-auth-oauth2/ #ConfigurationDirectory=openvpn-auth-oauth2 #ConfigurationDirectoryMode=0750 RuntimeDirectory=openvpn-auth-oauth2 ReadWritePaths=-/run/openvpn -/run/openvpn-server # We don't need write access anywhere. AmbientCapabilities= CapabilityBoundingSet= MemoryDenyWriteExecute=true NoNewPrivileges=true LockPersonality=true PrivateDevices=true PrivateTmp=true PrivateUsers=true ProcSubset=pid ProtectClock=true ProtectControlGroups=true ProtectHome=true ProtectHostname=true ProtectKernelLogs=true ProtectKernelModules=true ProtectKernelTunables=true ProtectProc=noaccess ProtectSystem=strict RemoveIPC=true RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 RestrictNamespaces=true RestrictRealtime=true RestrictSUIDSGID=true SystemCallArchitectures=native SystemCallFilter=@io-event @file-system @basic-io @system-service SystemCallFilter=~@clock @debug @module @mount @obsolete @privileged @reboot @resources @setuid @swap SystemCallErrorNumber=EPERM UMask=0027 [Install] WantedBy=multi-user.target