Question

If you try to pass the username/password to OpenVPN from a file via the --auth-user-pass switch, you get the following error:

"Sorry, 'Auth' password cannot be read from a file."

At least they're polite.

So our workaround was to programmatically write to "standard in" when we get the Auth Username: and Auth Password: prompts (this is in C#).

Something with the timing isn't 100% reliable, so I was looking for a way to pass the credentials to OpenVPN in a different way and came across this post: OpenVPN Post

It says you can recompile the source with a --enable-password-save option. Has anyone been able to do this?

My final question is: How can I pass an auth username/password to openvpn.exe on the client side? And does OpenVPNGUI somehow do this (maybe we can copy what they do)?

Was it helpful?

Solution 3

It turns out the problem wasn't with standard in.

I was using some locking where if the process exited in the middle of writing to standard in, there could be a deadlock.

There is no issue sending the password in this manner.

OTHER TIPS

It's possible to open a VPN connection via a script by using the following DOS command (however this is not recommended since the password is not encrypted)

$openvpn.exe config.ovpn < username < password

NOTE! param auth-user-pass not work if start by GUI "C:\Program Files\OpenVPN\config\name.ovpn"

Made start file start_openvpv.cmd (+ link to with "run as admin") with content:

cd C:\Users\Name\Documents\VPN
"C:\Program Files\OpenVPN\bin\openvpn.exe" --config C:\Users\Name\Documents\VPN\myvpnconfig.ovpn --auth-user-pass "C:\Users\Name\Documents\VPN\pass.txt"

pass.txt:

yourusername
yourpassword

OR put line to name.ovpn, as in upper messege:

auth-user-pass pass.txt

+start_openvpv.cmd:

cd C:\Users\Name\Documents\VPN
"C:\Program Files\OpenVPN\bin\openvpn.exe" --config C:\Users\Name\Documents\VPN\myvpnconfig.ovpn

For automatic authentication to Openvpn you have to modify the config.ovpn file.

-Go to OpenVPN\config directory and edit the .ovpn file

-Add this line to the config file -> auth-user-pass password.txt

-Then create the password.txt file and write in it:

yourusername
yourpassword

-After these steps your openvpn will connect automatically.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top