Save VPN Username/Password for OpenVPN Linux CLI
This tutorial explains how to save the OpenVPN credentials for the OpenVPN Command Line, CLI setup on Linux.
Step #1: We assume that your OpenVPN config file (.ovpn) is saved in the /etc/openvpn folder. Switch to the root user and create a new file there called pass.txt.
nano /etc/openvpn/pass.txt
Step #2: Enter your FastestVPN username on the first line and password on the second line. Make sure to enter the precise info and no space characters should be left at the beginning and end of the text.
Save the changes by pressing Ctrl+X and then Y.
Step #3: Now edit your desired OpenVPN server config file (.ovpn file) such as uk1-udp.ovpn by entering this command:
nano /etc/openvpn/uk1-udp.ovpn
Step #4: Find the line auth-user-pass and change it to auth-user-pass pass.txt
Save the changes by pressing Ctrl+X and then Y.
If you have multiple server config files in the folder and want to apply settings to all of them at once, run the following command:
sed -i 's/auth-user-pass/auth-user-pass pass.txt/g' *.ovpn
It means the line auth-user-pass in all .ovpn files will be changed to auth-user-pass pass.txt. Now all server files will take the credentials directly from your pass.txt file.