使用 auth-user-pass-verify 時 OpenVPN 伺服器無法啟動

使用 auth-user-pass-verify 時 OpenVPN 伺服器無法啟動

這是我的 OpenVPN 伺服器設定(完美運行)

local mydomain.com
port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh.pem
auth SHA512
tls-crypt tc.key
topology subnet
server 10.1.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DOMAIN subdomain.mydomain.com"
push "dhcp-option DNS 192.168.157.149"
push "block-outside-dns"
push "route 192.168.157.149 255.255.255.0"
push "route 0.0.0.0 192.0.0.0 net_gateway"
push "route 64.0.0.0 192.0.0.0 net_gateway"
push "route 128.0.0.0 192.0.0.0 net_gateway"
push "route 192.0.0.0 192.0.0.0 net_gateway"
push "route 10.0.0.0 255.255.255.0"
push "route 10.1.0.0 255.255.255.0"
keepalive 10 120
cipher AES-256-CBC
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
crl-verify crl.pem
explicit-exit-notify

我想允許使用具有不同用戶名的相同客戶端。所以我編輯了配置並在 server.conf 檔案中添加了以下幾行

script-security 2 # must be at least 2
auth-user-pass-verify /home/forge/scripts/checkUser.sh via-file
username-as-common-name # without this openvpn will use cn in the certificate as username
duplicate-cn # you may need this if everyone is using same certificate

透過在設定中新增此(上面)內容,openvpn 伺服器拒絕啟動。

為了調試,我對上面幾行進行了註釋,並一一取消註釋。所以現在我可以確定是該線路auth-user-pass-verify /home/forge/scripts/checkUser.sh via-file導致了問題。

沒有任何線索說明為什麼它在systemctl statusor中失敗journalctl -xe。該文件checkUser.sh可由系統中的任何使用者完全執行。日誌檔status-server.log也是空的。

雖然sudo systemctl start openvpn-server失敗,但直接運行 openvpn 可以:sudo openvpn --config /etc/openvpn/server/server.conf

看起來是這樣的:/lib/systemd/system/[email protected]

[Unit]
Description=OpenVPN service for %I
After=syslog.target network-online.target
Wants=network-online.target
Documentation=man:openvpn(8)
Documentation=https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO

[Service]
Type=notify
PrivateTmp=true
WorkingDirectory=/etc/openvpn/server
ExecStart=/usr/sbin/openvpn --status %t/openvpn-server/status-%i.log --status-version 2 --suppress-timestamps --config %i.conf
CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE CAP_AUDIT_WRITE
LimitNPROC=10
DeviceAllow=/dev/null rw
DeviceAllow=/dev/net/tun rw
ProtectSystem=true
ProtectHome=true
KillMode=process
RestartSec=5s
Restart=on-failure

[Install]
WantedBy=multi-user.target

有人可以指出可能是什麼問題嗎?

相關內容