Ubuntu – Vpn one-liner login script

aliasopenvpnvpn

I need to connect to VPN and it's quite tedious. I've tried to do one alias but for unknown reasons it failed.
Currently I use openvpn --config client.ovpn
Then it prompts me to type in the user-name and password and the token form G auth. But I want to do it in-one line and have alias for that. like alias vpn="openvpn --config client.ovpn -uname: r.balejik pass: fkjgndfk1fgf" is it possible to have kinda one liner? and also this alias doesn't work for some strange reasons when I sourced .bashrc . Or some bash script is a better option?

Thanks,

Rob.

Best Answer

You can add an alias to .bash_profile. You should specify a path to your client.vpn otherwise you might need to be in that folder when you execute vpn.

alias vpn="openvpn --config /home/user/openvpn/client.ovpn"

You then can create a file that contains your username and password and reference it from your client.ovpn.

First thing, create a file called credentials.txt in the same folder as your client.ovpn.

nano credentials.txt

Inside that file, store your username and password.

username
password

Save the file, then open client.ovpn and add the following directive.

auth-user-pass credentials.txt

Once again, credentials.txt needs to be in the same folder as client.opvn as it's going to look there for that file.

Related Question