Bash Script: Connect To Free VPN ProtonVPN With OpenVPN Configs

ProtonVPN allows to use Free VPN servers in Netherlands, USA, Japan. You may use official application for Linux, Android. But for fine configuring and connect just in one click need to connect with own script using OpenVPN configs by ProtonVPN. Here it is my own bash script for connect to the best protonvpn server in one click.

0. Prerequisits

Intall tor, torsocks, openvpn, resolvconf, jq

apt-get install tor torsocks openvpn resolvconf jq

Resolvconf is for protonvpn updates /etc/resolv.conf when connects via openvpn.

Jq is for parse servers list file.

Tor, torsocks are for download servers list via tor (because protonvpn domain can be blocked in some countries, in Russia it was for some time).

 

1. Create account if you still have not

https://protonvpn.com Account on this site is the same as on ProtonMail.com. Sometimes it requires verification by SMS.

2. Choose free plan on ptotonvpn and create VPN account

After that you will be able to get OpenVPN login and password here: https://account.protonvpn.com/account

Create file with two lines: logins and password and put it to /home/user/configs/protonvpn

3. Download OpenVPN config files

On the download page find OpenVPN configs and download all free servers configs (or just that you will use): https://account.protonvpn.com/downloads

And put them to /root/vpn/protonvpn/

 

# ls /root/vpn/protonvpn
jp-free-01.protonvpn.com.udp.ovpn  nl-free-06.protonvpn.com.udp.ovpn  nl-free-18.protonvpn.com.udp.ovpn  nl-free-31.protonvpn.com.udp.ovpn  us-free-09.protonvpn.com.udp.ovpn
jp-free-02.protonvpn.com.udp.ovpn  nl-free-07.protonvpn.com.udp.ovpn  nl-free-19.protonvpn.com.udp.ovpn  nl-free-36.protonvpn.com.udp.ovpn  us-free-10.protonvpn.com.udp.ovpn
jp-free-03.protonvpn.com.udp.ovpn  nl-free-08.protonvpn.com.udp.ovpn  nl-free-20.protonvpn.com.udp.ovpn  nl-free-37.protonvpn.com.udp.ovpn  us-free-11.protonvpn.com.udp.ovpn
jp-free-04.protonvpn.com.udp.ovpn  nl-free-09.protonvpn.com.udp.ovpn  nl-free-21.protonvpn.com.udp.ovpn  nl-free-38.protonvpn.com.udp.ovpn  us-free-12.protonvpn.com.udp.ovpn
jp-free-05.protonvpn.net.udp.ovpn  nl-free-10.protonvpn.com.udp.ovpn  nl-free-22.protonvpn.com.udp.ovpn  us-free-01.protonvpn.com.udp.ovpn  us-free-13.protonvpn.com.udp.ovpn
jp-free-06.protonvpn.net.udp.ovpn  nl-free-11.protonvpn.com.udp.ovpn  nl-free-23.protonvpn.com.udp.ovpn  us-free-02.protonvpn.com.udp.ovpn  us-free-14.protonvpn.com.udp.ovpn
jp-free-07.protonvpn.com.udp.ovpn  nl-free-12.protonvpn.net.udp.ovpn  nl-free-24.protonvpn.com.udp.ovpn  us-free-03.protonvpn.com.udp.ovpn  us-free-22.protonvpn.com.udp.ovpn
nl-free-01.protonvpn.com.udp.ovpn  nl-free-13.protonvpn.com.udp.ovpn  nl-free-25.protonvpn.com.udp.ovpn  us-free-04.protonvpn.com.udp.ovpn  us-free-23.protonvpn.com.udp.ovpn
nl-free-02.protonvpn.com.udp.ovpn  nl-free-14.protonvpn.com.udp.ovpn  nl-free-26.protonvpn.com.udp.ovpn  us-free-05.protonvpn.com.udp.ovpn  us-free-24.protonvpn.com.udp.ovpn
nl-free-03.protonvpn.com.udp.ovpn  nl-free-15.protonvpn.com.udp.ovpn  nl-free-27.protonvpn.com.udp.ovpn  us-free-06.protonvpn.com.udp.ovpn  us-free-25.protonvpn.com.udp.ovpn
nl-free-04.protonvpn.com.udp.ovpn  nl-free-16.protonvpn.com.udp.ovpn  nl-free-28.protonvpn.com.udp.ovpn  us-free-07.protonvpn.com.udp.ovpn  us-free-26.protonvpn.com.udp.ovpn
nl-free-05.protonvpn.com.udp.ovpn  nl-free-17.protonvpn.com.udp.ovpn  nl-free-30.protonvpn.com.udp.ovpn  us-free-08.protonvpn.com.udp.ovpn
 

4. Download bash script and give right to execute

Here it is my bash script: https://gitgud.io/youni/devuan-config-files/-/blob/master/op

Put it to /usr/scripts/op for example

wget https://gitgud.io/youni/devuan-config-files/-/raw/master/op -O /usr/scripts/op

chmod +x /usr/scripts/op

vim /usr/scripts/op

And also check its config: folder with ovpn files and path to login/pass file.

 

5. Add alias, add sudo rights and run

For run as usual user add to /etc/sudoers (if your distribution works on SysVinit):

%netdev    ALL=(root) NOPASSWD:   /usr/sbin/service, /etc/init.d/tor, /usr/sbin/openvpn, /usr/scripts/op, /usr/scripts/vpnstop.sh

Where %netdev is group of usual user. You may use %sudo instead if your usual user belongs to sudo group.

Add alias to ~/.bash_aliases

alias op='sudo /usr/scripts/op'

Run:

op

And this will download list of servers, choose the less loaded and will connect to it.

For help use:

op -h

 

For issues or questions use Stackoverflow or reddit.

 

Links

  1. Official ProtonVPN site https://protonvpn.com
  2. My bash script https://gitgud.io/youni/devuan-config-files/-/blob/master/op
  3. ProtonVPN servers list https://api.protonmail.ch/vpn/logicals
Section
Category