因此,我一直在查看基于 Debian 9 的服务器上的 openvpn 配置,发现了一些我无法在 openvpn 守护程序的 systemd 单元文件中解释的内容。守护进程本身正在启动并正常工作,但我不知道为什么......让我解释一下:)
所以我已经安装了 openvpn 并在/etc/openvpn/server.conf文件中进行了正确的配置。到目前为止没有任何问题。
但是,显然有两个 systemd 单元正在为 openvpn 运行,即openvpn.service和openvpn@server.service。后者似乎是实际接受传入的 vpn 连接的一种,而前者似乎根本没有做太多事情。它显然只是为了启动后者,我想......
检查/etc/systemd/system/multi-user.target.wants/目录中是否有 openvpn 相关文件只显示 openvpn.service 文件,其中的源文件是指向 /lib/systemd/system 中类似命名文件的符号链接。这个文件的内容是:
# This service is actually a systemd target,
# but we are using a service since targets cannot be reloaded.
[Unit]
Description=OpenVPN service
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecReload=/bin/true
WorkingDirectory=/etc/openvpn
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
嗯不错。所以这只运行/bin/true。那么究竟是什么启动了openvpn@server守护进程呢?我知道这个单元文件是/lib/systemd/openvpn@.service但我在我的系统上找不到任何线索来确切地运行这个单元文件。(我期待在/etc/systemd/system下找到一个符号链接,但没有。)这个文件的内容是:
[Unit]
Description=OpenVPN connection to %i
PartOf=openvpn.service …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Ubuntu 远程服务器上运行 OpenVPN。我一直在关注这个教程。截至目前,我正处于第 3 步之前,尝试获取“VPN '服务器'正在运行”消息。然而,当我跑步时
service openvpn start
service openvpn status
Run Code Online (Sandbox Code Playgroud)
我得到:
“活动(已退出),代码=已退出,状态=0/成功”响应。
我尝试检查日志:
vim /var/log/syslog
Run Code Online (Sandbox Code Playgroud)
但没有看到任何可疑的东西:
这种行为背后的原因可能是什么?
我有用户 2 因素身份验证的 openvpn 配置。
如果我手动启动它,运行:
/usr/sbin/openvpn --writepid /run/whatever --cd /etc/openvpn/ --config /etc/openvpn/work.conf
Run Code Online (Sandbox Code Playgroud)
它要求输入用户名,然后是密码(由我手机上的软件提供),然后是私钥的密码。然后它起作用了。
但是,如果/当我尝试通过普通服务调用启动它时:
=# service openvpn start work
Run Code Online (Sandbox Code Playgroud)
没有打印任何内容,openvpn 不起作用,并且 journalctl 显示:
=# systemctl status openvpn
? openvpn.service - OpenVPN service
Loaded: loaded (/lib/systemd/system/openvpn.service; enabled; vendor preset: enabled)
Active: active (exited) since czw 2015-05-28 10:24:22 CEST; 17min ago
Process: 30395 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 30395 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/openvpn.service
maj 28 10:24:22 krowka systemd[1]: Starting OpenVPN service...
maj 28 10:41:40 krowka systemd[1]: Started OpenVPN service.
Run Code Online (Sandbox Code Playgroud)
除了手动构建 /usr/sbin/openvpn …