ProtonVPN at startup on Linux
ProtonVPN is a great VPN solution which includes also a free tier. Some months ago they've released an updated version of their command-line tool which allows you to connect to the ProtonVPN servers directly. However, this new version is not compatible out-of-the-box with the previous version. It gave me a lot of headaches to find a way to run it automatically at startup on my Raspberry Pi.
If you want to run something at startup, the best idea is to run it as a service. This gives you a lot of control regarding when to run it, how to stop it, etc. After you followed the installation instructions on the website, you will need to define a new service, which starts after the network connection has been established. It will also need to run as
, or it will fail to start (running as root user does not work on Ubuntu/Debian systems). The first step is to know where the protonvpn command was installed on your system:
sudo which protonvpn
The output should be something like:
, but if it is not, pay attention and change it in the code block below.
Create a file
in the folder
, and add the following:
[Unit] Description=ProtonVPN-CLI auto-connect Wants=network-online.target [Service] Type=forking ExecStart=/usr/local/bin/protonvpn connect -f Environment=PVPN_WAIT=300 Environment=PVPN_DEBUG=1 Environment=SUDO_USER=user [Install] WantedBy=multi-user.target
Remember to change the line
with the appropriate user name, for example
, etc. Also, if you want to change the type of connection, you should edit the line starting with
with whatever command you would like to run.
Once you have it, you just need to enable it and start it:
sudo systemctl daemon-reload sudo systemctl enable protonvpn sudo systemctl start protonvpn
You can check the status of proton vpn in two different ways, by monitoring the status of the service or by using the command line tool itself:
sudo systemctl status protonvpn protonvpn status
If you ever want to stop or restart the service, you can do:
sudo systemctl restart protonvpn sudo systemctl stop protonvpn
Note that solutions based on
tend not to work properly, since they tend to run before the network becomes active, and thus the command will fail.