You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

配置systemd实现ProtonVPN自动启动失败,寻求技术帮助

解决ProtonVPN-CLI通过systemd自动连接的报错问题

当前systemd服务配置

我的/etc/systemd/system/protonvpn.service文件内容:

[Unit]
Description=ProtonVPN-CLI auto-connect
Wants=network-online.target
After=network-online.target

[Service]
Type=forking
ExecStart=/usr/bin/protonvpn c -f
Environment=PVPN_WAIT=300
Environment=PVPN_DEBUG=1
Environment=SUDO_USER=aleph
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

已执行的命令

sudo systemctl daemon-reload
sudo systemctl enable protonvpn
sudo systemctl start protonvpn

报错日志

May 31 17:22:18 vivo systemd[1]: Starting protonvpn.service - ProtonVPN-CLI auto-connect...
░░ Subject: A start job for unit protonvpn.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit protonvpn.service has begun execution.
░░ 
░░ The job identifier is 2874.
May 31 17:22:18 vivo (rotonvpn)[26853]: protonvpn.service: Unable to locate executable '/usr/local/bin/protonvpn': No such file or directory
░░ Subject: Process /usr/local/bin/protonvpn could not be executed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The process /usr/local/bin/protonvpn could not be executed and failed.
░░ 
░░ The error number returned by this process is 2.
May 31 17:22:18 vivo (rotonvpn)[26853]: protonvpn.service: Failed at step EXEC spawning /usr/local/bin/protonvpn: No such file or directory
░░ Subject: Process /usr/local/bin/protonvpn could not be executed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The process /usr/local/bin/protonvpn could not be executed and failed.
░░ 
░░ The error number returned by this process is 2.
May 31 17:22:18 vivo systemd[1]: protonvpn.service: Control process exited, code=exited, status=203/EXEC
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit protonvpn.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 203.
May 31 17:22:18 vivo systemd[1]: protonvpn.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit protonvpn.service has entered the 'failed' state with result 'exit-code'.
May 31 17:22:18 vivo systemd[1]: Failed to start protonvpn.service - ProtonVPN-CLI auto-connect.
░░ Subject: A start job for unit protonvpn.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit protonvpn.service has finished with a failure.
░░ 
░░ The job identifier is 2874 and the job result is failed.
May 31 17:25:04 vivo systemd[1]: Starting protonvpn.service - ProtonVPN-CLI auto-connect...
░░ Subject: A start job for unit protonvpn.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit protonvpn.service has begun execution.
░░ 
░░ The job identifier is 3186.
May 31 17:25:05 vivo protonvpn[37672]: Error: Unknown action 'c' for 'protonvpn' command.
May 31 17:25:05 vivo protonvpn[37672]: Available actions:
May 31 17:25:05 vivo protonvpn[37672]:   signin       Sign in to Proton VPN with your credentials.
May 31 17:25:05 vivo protonvpn[37672]:   signout      Sign out from Proton VPN and clear local credentials.
May 31 17:25:05 vivo protonvpn[37672]:   info         Display your Proton VPN account information.
May 31 17:25:05 vivo protonvpn[37672]:   connect      Connect to Proton VPN server.
May 31 17:25:05 vivo protonvpn[37672]:   disconnect   Disconnect from current VPN server.
May 31 17:25:05 vivo protonvpn[37672]:   status       Show current VPN connection status.
May 31 17:25:05 vivo protonvpn[37672]:   servers      View available servers.
May 31 17:25:05 vivo protonvpn[37672]:   countries    Discover all countries where Proton VPN servers are available.
May 31 17:25:05 vivo protonvpn[37672]:   cities       Discover cities where servers are available in a specific country.
May 31 17:25:05 vivo protonvpn[37672]:   config       Configure Proton VPN settings.
May 31 17:25:05 vivo protonvpn[37672]: Try 'protonvpn --help' for more information.
May 31 17:25:05 vivo systemd[1]: protonvpn.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit protonvpn.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 2.
May 31 17:25:05 vivo systemd[1]: protonvpn.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit protonvpn.service has entered the 'failed' state with result 'exit-code'.
May 31 17:25:05 vivo systemd[1]: Failed to start protonvpn.service - ProtonVPN-CLI auto-connect.
░░ Subject: A start job for unit protonvpn.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit protonvpn.service has finished with a failure.
░░ 
░░ The job identifier is 3186 and the job result is failed.
May 31 17:41:13 vivo systemd[1]: Starting protonvpn.service - ProtonVPN-CLI auto-connect...
░░ Subject: A start job for unit protonvpn.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit protonvpn.service has begun execution.
░░ 
░░ The job identifier is 4037.
May 31 17:41:14 vivo protonvpn[108695]: Error: Unknown action 'c' for 'protonvpn' command.
May 31 17:41:14 vivo protonvpn[108695]: Available actions:
May 31 17:41:14 vivo protonvpn[108695]:   signin       Sign in to Proton VPN with your credentials.
May 31 17:41:14 vivo protonvpn[108695]:   signout      Sign out from Proton VPN and clear local credentials.
May 31 17:41:14 vivo protonvpn[108695]:   info         Display your Proton VPN account information.
May 31 17:41:14 vivo protonvpn[108695]:   connect      Connect to Proton VPN server.
May 31 17:41:14 vivo protonvpn[108695]:   disconnect   Disconnect from current VPN server.
May 31 17:41:14 vivo protonvpn[108695]:   status       Show current VPN connection status.
May 31 17:41:14 vivo protonvpn[108695]:   servers      View available servers.
May 31 17:41:14 vivo protonvpn[108695]:   countries    Discover all countries where Proton VPN servers are available.
May 31 17:41:14 vivo protonvpn[108695]:   cities       Discover cities where servers are available in a specific country.
May 31 17:41:14 vivo protonvpn[108695]:   config       Configure Proton VPN settings.
May 31 17:41:14 vivo protonvpn[108695]: Try 'protonvpn --help' for more information.
May 31 17:41:14 vivo systemd[1]: protonvpn.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit protonvpn.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 2.
May 31 17:41:14 vivo systemd[1]: protonvpn.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit protonvpn.service has entered the 'failed' state with result 'exit-code'.
May 31 17:41:14 vivo systemd[1]: Failed to start protonvpn.service - ProtonVPN-CLI auto-connect.
░░ Subject: A start job for unit protonvpn.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit protonvpn.service has finished with a failure.
░░ 
░░ The job identifier is 4037 and the job result is failed.

问题分析

从日志能定位三个核心问题:

  1. 命令参数不兼容:报错明确提示Unknown action 'c',当前版本的ProtonVPN-CLI不支持短选项c,必须使用完整的connect命令。
  2. 旧配置残留:初始报错显示尝试调用/usr/local/bin/protonvpn,说明存在旧service配置残留,或daemon-reload未完全生效。
  3. 运行上下文错误:默认systemd服务以root用户运行,而ProtonVPN的登录凭证存储在用户目录下,root身份无法读取用户aleph的VPN配置。

修复方案

1. 更新systemd服务配置

替换/etc/systemd/system/protonvpn.service内容为:

[Unit]
Description=ProtonVPN-CLI auto-connect
Wants=network-online.target
After=network-online.target
Requires=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/protonvpn connect -f
Environment=PVPN_WAIT=300
Environment=PVPN_DEBUG=1
User=aleph
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
  • 改Type=forking为Type=oneshot:适配protonvpn connect -f的一次性执行特性,配合RemainAfterExit=yes让systemd识别服务为活跃状态。
  • 替换c为connect:匹配当前CLI的命令格式。
  • 添加User=aleph:让服务以指定用户身份运行,确保能读取用户的VPN凭证。
  • 添加Requires=network.target:强制依赖网络服务,避免提前启动导致连接失败。

2. 清理残留并重新加载配置

执行以下命令:

# 停止当前服务
sudo systemctl stop protonvpn
# 检查是否存在其他同名服务文件
ls /etc/systemd/system/protonvpn* /usr/lib/systemd/system/protonvpn*
# 若有旧文件则删除,然后重新加载配置
sudo systemctl daemon-reload
# 重新启用并启动服务
sudo systemctl enable --now protonvpn

3. 验证连接状态

执行命令确认服务和VPN状态:

sudo systemctl status protonvpn
protonvpn status

内容的提问来源于stack exchange,提问作者Aleph

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.02 07:59:51