0

I already have OpenVPN set to start automatically. That was easy enough, as there is a checkbox in settings, which automatically sets the OpenVPN service to automatic. I tried that out by restarting the desktop and it works.

I have several (4 at the moment) connection scripts. OpenVPN stores them nicely in the config folder. I can select "Connect" to the appropriate site and I get a connection. I set up silent. That works nicely too.

What I could not figure out how to do is that OpenVPN automatically connects to my sites, when I login to my computer.

I have my OVPN extension files stored nicely in my folder:

C:\Users\<user>\OpenVPN\config

I did research and came up with OpenVPN Server, but I am not interested in going the other way. I just want to automatically connect to the server, when I log into the computer.

OpenVPN Settings

OpenVPN Client Settings Tab

OpenVPN About

OpenVPN About Box Tab

OpenVPN Log On

OpenVPN Log On Tab

My research turned up the following command, which I thought to schedule a minute or two after my computer starts.

openvpn-gui.exe --connect C:\Users\username\OpenVPN\config\ClientConnection1\clientconnection1.ovpn

I can discount the line above for two reasons.

  1. I tried the command after OpenVPN was started and it did not work. Yes, I tried from an Administrative command window. I am not surprised as OpenVPN is already started. That gets me into point #2. (Yes, I realize that I can start OpenVPN manually and have Task Scheduler run the above command.)

  2. I want to automatically connect on my desktop to 4 (could be any number) of sites automatically and the command line offers support for one.

How is that achieved?

Thoughts?

strong textUPDATE

Per the below comment, I copied my script files to the config-auto folder as follows:

C:\Program Files\OpenVPN\config-auto
    client-connect1 (a subdirectory)
    README.txt
C:\Program Files\OpenVPN\config-auto\client-connect1
    caConnection1.crt
    clientConnection1.crt
    clientConnection1.key
    clientConnection1.ovpn

The contents of the script are:

client
dev tap
proto udp
dev-node NETGEAR-VPN
remote connection1.ddns.net 12974
resolv-retry infinite
nobind
key-direction 1
persist-key
persist-tun
ca caConnection1.crt
cert clientConnection1.crt
key clientConnection1.key
cipher AES-128-CBC
comp-lzo
verb 5

As stated, the script works when placed in either config folder.

I restarted the computer (twice now) with the config files in the config-auto folder as shown above, and nothingness, even after 5-minutes waiting.

I did see, thank you, this README.txt file in the config-auto directory substantiating the comment, just it does not work.

This directory or its subdirectories should contain OpenVPN
configuration files each having an extension of .ovpn
that should be automatically started at boot up.

When OpenVPNService is started, a separate OpenVPN
process will be instantiated for each configuration file.

OpenVPN GUI does not scan this directory.

UPDATE

I found the log file and here is the problem, so progress, just have to solve it now.

2021-04-10 18:26:50 WARNING: Compression for receiving enabled. Compression has been used in the past to break encryption. Sent packets are not compressed unless "allow-compression yes" is also set.
2021-04-10 18:26:50 us=900373 DEPRECATED OPTION: --cipher set to 'AES-128-CBC' but missing in --data-ciphers (AES-256-GCM:AES-128-GCM). Future OpenVPN version will ignore --cipher for cipher negotiations. Add 'AES-128-CBC' to --data-ciphers or change --cipher 'AES-128-CBC' to --data-ciphers-fallback 'AES-128-CBC' to silence this warning.
Options error: --ca fails with 'catheclient.crt': No such file or directory (errno=2)
Options error: --cert fails with 'clienttheclient.crt': No such file or directory (errno=2)
2021-04-10 18:26:50 us=900373 WARNING: cannot stat file 'clienttheclient.key': No such file or directory (errno=2)
Options error: --key fails with 'clienttheclient.key': No such file or directory (errno=2)
Options error: Please correct these errors.
Use --help for more information.
  1. OpenVPN continuously attempts to connect, not just once. The log file shows connection attempts every minute or so.
  2. The 3 files in question are in the same directory, a subdirectory of the config/auto-config folder. I might need to hard code the entire path.
11
  • Try the \Program Files\OpenVPN\config-auto folder for your .ovpn configuration files. This should start a separate OpenVPN process on each file.
    – harrymc
    Commented Apr 3, 2021 at 16:50
  • @harrymc Thank you for the quick comment. Does not work, see update on my question. I placed the config file in the config-auto directory. I did not see that directory yesterday. I did see the README.txt file, which says the same thing as what you wrote. I MOVED the config files there, restarted the computer (twice), waited about 5-minutes, and nothing. If I copy the files back to either config folder and restart the GUI, then I am able to manually connect. I did verify that OpenVPN Service does start after the reboot. Commented Apr 3, 2021 at 18:35
  • Have you installed and started the OpenVPNService? OpenVPN needs to be installed as a service, see Running OpenVPN as a Windows Service.
    – harrymc
    Commented Apr 3, 2021 at 19:29
  • @harrymc I stated in my question and my last comment that the OpenVPNService starts nicely and is set to automatic. I am happy to furnish a screenshot if you want, though I do not wish to make the question overtly long. Commented Apr 3, 2021 at 21:19
  • Automatic might start too early. Try manual.
    – harrymc
    Commented Apr 3, 2021 at 21:27

1 Answer 1

0

The log file definitely helped, however the OpenVPN Notes page is slightly incorrect.

  1. The OpenVPN Service looks at the config-auto first and ignores, at least by the same name, contents in the config folder.

  2. I had to hard code the path, so:

    client dev tap proto udp dev-node NETGEAR-VPN remote theclient2.ddns.net 12974 resolv-retry infinite nobind key-direction 1 persist-key persist-tun ca "C:/Program Files/OpenVPN/config/client-Th/caTheClient2.crt" cert "C:/Program Files/OpenVPN/config/client-TheClient2/clientTheClient2.crt" key "C:/Program Files/OpenVPN/config/client-TheClient2/clientTheClient2.key" cipher AES-128-CBC comp-lzo verb 5

I use a forward slash, as I have experience with Linux based tools, even ported to Windows, that they do not like the Windows backslashes, even sometimes if doubled, so I just KISS and used a forward slash.

I then opened a command/terminal window, and issued "ping 10.0.0.1" and success!

The log files stays static, no new entries.

Finally.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .