openvpn 作为服务启动时失败

openvpn 作为服务启动时失败

设置

OpenVPN 充当客户在 Ubuntu 16.04.4 LTS 机器上。 openvpn 配置存储在 中/etc/openvpn/myclient.conf。所有其他数据(例如密钥)也存储在 conf 文件中。

# openvpn --version

**`OpenVPN 2.3.10`**` x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Jan  9 2019
library versions: OpenSSL 1.0.2g  1 Mar 2016, LZO 2.08

问题

当尝试启动 openvpn 作为服务时,启动失败

 # systemctl start [email protected]
    Job for [email protected] failed because the control process exited with error code. See "systemctl status [email protected]" and "journalctl -xe" for details.



# systemctl status [email protected][email protected] - OpenVPN connection to myclient
   Loaded: loaded (/lib/systemd/system/[email protected]; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since So 2019-08-04 13:03:33 CEST; 1min 44s ago
     Docs: man:openvpn(8)
           https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage
           https://community.openvpn.net/openvpn/wiki/HOWTO
  Process: 16134 ExecStart=/usr/sbin/openvpn --daemon ovpn-%i --status /run/openvpn/%i.status 10 --cd /etc/openvpn --script-security 2 --config /etc/openvpn/%i.conf --writepid /run/openvpn/%i.pid (code=exited, status=1/FAILURE)

Aug 04 13:03:33 hostname systemd[1]: Starting OpenVPN connection to myclient...
Aug 04 13:03:33 hostname systemd[1]: [email protected]: Control process exited, code=exited status=1
Aug 04 13:03:33 hostname systemd[1]: Failed to start OpenVPN connection to myclient.
Aug 04 13:03:33 hostname systemd[1]: [email protected]: Unit entered failed state.
Aug 04 13:03:33 hostname systemd[1]: [email protected]: Failed with result 'exit-code'.

journalctl 显示openvpn 无法打开配置文件

# journalctl -xe

-- Unit [email protected] has begun starting up.`**`
Aug 04 13:10:03 hostname ovpn-myclient[17349]: Options error: In [CMD-LINE]:1: Error opening configuration file: /etc/openvpn/myclient.conf`**`
Aug 04 13:10:03 hostname ovpn-myclient[17349]: Use --help for more information.
Aug 04 13:10:03 hostname systemd[1]: [email protected]: Control process exited, code=exited status=1
Aug 04 13:10:03 hostname systemd[1]: Failed to start OpenVPN connection to myclient.

[...]

Aug 04 13:10:03 hostname systemd[1]: [email protected]: Unit entered failed state.
Aug 04 13:10:03 hostname systemd[1]: [email protected]: Failed with result 'exit-code'.

然而,手动启动 openvpn通过# openvpn --config /etc/openvpn/myclient.conf 按预期工作

我尝试过的方法

  • 更改配置文件权限(从 644 到 755;该文件归 root:root 所有)
  • 检查应用装甲(没有 openvpn 的配置文件,完全禁用 apparmor 也无济于事)
  • 重命名配置文件并重试

相关内容