I recently purchased a VPN subscription from Fastest VPN, with the purpose of using it on Linux, via SSH, command line only. They don’t offer anything special about Linux and the command line, they just use OpenVPN.
How it works: simply install OpenVPN (for example with sudo apt install openvpn
), then download the configuration files (for example, these are the files for Fastest VPN) and just write sudo openvpn nomeserver.ovpn
to connect.
But there is a big problem: each time you have to write the password by hand! Intolerable, especially with a complex password. Luckily there is a shortcut.
You can create a file with credentials. In a directory accessible only to you, create a file called login.conf
and enter, on two lines, username and password, like this:
Username
Password
At this point we modify the *.ovpn
files of the configuration. For example, open Luxembourg-UDP.ovpn
and see the auth-user-pass
entry. We replace it with auth-user-pass login.conf
, so when we load the configuration with openvpn, our credentials are auto-filled. Now though, here are 50 files, one for each server. Do we open the files one by one and edit them by hand? No way! sed
was invented on purpose.
Just write it down:
sed -i 's/auth-user-pass/auth-user-pass login.conf/g' *.ovpn
and automatically all lines with auth-user-pass
will be changed with auth-user-pass login.conf
. So, when we download the updated server configurations, they will continue to work perfectly!