I have a server with OpenVPN installed on it, and I also have laptops (clients) running Ubuntu with openvpn installed. On the client, if I manually run the command "sudo openvpn /etc/openvpn/client.conf" the client is configured to prompt me for login info (username and password) which it will then use in authentication with the server. I would like this process to happen automatically on startup. Basically, I need logging into the client laptop and logging into the openvpn server to be the same action. I want the the authentication information for logging into openvpn to be the same as the login information for logging into the laptop's local user account. How can I do this?? Details please.

  • Does it have to be Username/Password? I know you can do this via pubkey auth on /etc/network/if-up.d Jun 1, 2016 at 20:43
  • What would the method you are talking about entail?
    – Tommy Orok
    Jun 1, 2016 at 20:59

2 Answers 2


I assume You have downloaded an .ovpn file with the information about the vpn.

Create a file in the same folder called auth.txt and insert in its first line the username of your vpn login, in second line the vpn password, e.g.:


Save the file and close it. Edit Your .ovpn file: find the line starting with auth-user-pass and add auth.txt. Save the file and close it.

enter image description here

I would write the full path to auth.txt e.g. auth-user-pass /etc/openvpn/auth.txt but (at least on Ubuntu) it also works with just the filename, if in the same folder.

Now You should be able to call sudo openvpn <.ovpn file> without providing credentials (apart from the sudo password).

I based information on here and here

There is a small note how to autorun scripts on system boot: here


Use "auth-user-pass credentials-file.txt" option in your client config file. The credentials file should be in the form:


Yes, you will have the plaintext file with username and password.

  • Thank you so much for your reply, but that only tells me how I would take care of the automatic authorization part. How do I configure openvpn to start upon login in the first place?
    – Tommy Orok
    Jun 2, 2016 at 10:30
  • Try to run it from bash-profile or so. Implement locking to not to run it more than once. Jun 8, 2016 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.