Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenVPN on Linux: passing username and password in command line

I am using IPVanish for using a proxy while surfing; like:

sudo openvpn --config /home/ipv/conf/ipvanish-CA-Toronto-tor-a09.ovpn 

Now, I have to enter my username, after that my password. How Can I pass those two params right as one command, so that I just use one command and the username/password are being passed automatically?

like image 485
JOhnlw009a Avatar asked Aug 10 '16 09:08

JOhnlw009a


People also ask

How do I pass a username and password in Linux?

passwd -n <no of days> <username> This means user2 cannot change its own password until 10 days have passed. To confirm the password setting made with the -n option above, run the following command: # passwd -S user1 user1 PS 2020-12-04 10 99999 7 -1 (Password set, SHA512 crypt.)

How do I add a username and password to OVPN?

Set Username/Password for each client on OpenVPN serverClick Account tab, and then click Add Account to set the username and password for VPN client. Enter the client's name and assign an password for the client. Click Save. Repeat above steps to set username/password for each client.


1 Answers

The previous answer didn't work for me (still asked for username and password), what did work was putting your credentials in a file (pass.txt), like this

[email protected] password 

and calling openvpn with --auth-user-pass pass.txt.

source

Note that in some OpenVPN versions (e.g. OpenVPN 2.4.11) there is a bug where you have to first use --config and then --auth-user-pass or your auth file will be ignored without any warning.

So, here a complete example:

sudo openvpn --config /home/ipv/conf/ipvanish-CA-Toronto-tor-a09.ovpn --auth-user-pass pass.txt 
like image 120
Fluffy Avatar answered Sep 18 '22 10:09

Fluffy