{"id":6522,"date":"2020-07-28T22:20:14","date_gmt":"2020-07-28T19:20:14","guid":{"rendered":"https:\/\/kifarunix.com\/?p=6522"},"modified":"2024-03-14T22:04:56","modified_gmt":"2024-03-14T19:04:56","slug":"configure-openvpn-to-prompt-for-credentials-on-logon-on-windows-systems","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/configure-openvpn-to-prompt-for-credentials-on-logon-on-windows-systems\/","title":{"rendered":"Configure OpenVPN to Prompt for Credentials on Logon on Windows Systems"},"content":{"rendered":"\n<p>Welcome to our tutorial on how to configure OpenVPN to prompt for credentials on logon on Windows systems.<\/p>\n\n\n\n<p>In most cases, you may want to <a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/openvpn.net\/community-resources\/configuring-openvpn-to-run-automatically-on-system-startup\/\" target=\"_blank\" rel=\"noreferrer noopener\">configure OpenVPN to run automatically on system startup<\/a>. However, if you are using authentication based OpenVPN setup, it means that for this to work, you need to put your OpenVPN credentials on a file so that they can always be read while automatic connection is being initiated. But, in the cases that the password keeps changing after a specific duration of time, then you would better configure your OpenVPN such that, everytime you login to your system, you are prompted to enter your OpenVPN credentials.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring OpenVPN to Prompt for Credentials on Logon on Windows Systems<\/h2>\n\n\n\n<p>Note that this setup was tested on a Windows 7 ultimate system. The procedure, however, applies to other Windows systems including Windows 10.<\/p>\n\n\n\n<p>Also, note that, this setup utilizes, <strong><code>openvpn-gui.exe<\/code><\/strong> service rather than the <code><strong>openvpn.exe<\/strong><\/code> client command.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install OpenVPN Client on Windows<\/h3>\n\n\n\n<p>Navigate to <a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/openvpn.net\/community-downloads\/\" target=\"_blank\" rel=\"noreferrer noopener\">OpenVPN Community Downloads page<\/a> and grab the OpenVPN installer for your system.<\/p>\n\n\n\n<p>Once the download is complete, double click the installer to launch the installation of OpenVPN client on your Windows system.<\/p>\n\n\n\n<p>The installation is as easy as clicking <strong>Next<\/strong>, <strong>Next<\/strong>.<\/p>\n\n\n\n<p>Choose your OpenVPN installation destination folder. In this setup, we set the installation folder to <code>C:\\Program Files\\OpenVPN<\/code>.<\/p>\n\n\n\n<p>Once you have set your destination folder, click <strong>Install<\/strong> to proceed with installation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install OpenVPN Client Configuration file<\/h3>\n\n\n\n<p>Once the OpenVPN client is installed, obtain the client configuration file, and place it in the same directory where the OpenVPN binary\/executable files resides, <code><strong>C:\\Program Files\\OpenVPN\\bin<\/strong><\/code>.<\/p>\n\n\n\n<p>Ensure that the client configuration file has the <strong><code>.ovpn<\/code><\/strong> extension.<\/p>\n\n\n\n<p>In my setup, my OpenVPN client configuration file is named <strong><code>kifarunix-demo-vpn.ovpn<\/code><\/strong>.<\/p>\n\n\n\n<p>For the purposes of demo, below are the contents of my OpenVPN client configuration file, <strong><code>kifarunix-demo-vpn.ovpn<\/code><\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>client\ntls-client\npull\ndev tun\nproto udp4\nremote 192.168.58.5 1194\nresolv-retry infinite\nnobind\npersist-key\npersist-tun\nkey-direction 1\nremote-cert-tls server\nauth-nocache\ncomp-lzo\nverb 3\nauth SHA512\n&lt;tls-auth&gt;\n#\n# 2048 bit OpenVPN static key\n#\n-----BEGIN OpenVPN Static key V1-----\n...\n...\n-----END OpenVPN Static key V1-----\n&lt;\/tls-auth&gt;\n&lt;ca&gt;\n-----BEGIN CERTIFICATE-----\nMIIDXTCCAkWgAwIBAgIURO2qNFJy57yCdVRJdfZui6MSzs8wDQYJKoZIhvcNAQEL\n...\n...\nDg==\n-----END CERTIFICATE-----\n&lt;\/ca&gt;\n&lt;cert&gt;\nCertificate:\n ...\n ...\n-----BEGIN CERTIFICATE-----\nMIIDZDCCAkygAwIBAgIRAOvU4d4QdDYDAOOvMX26OIUwDQYJKoZIhvcNAQELBQAw\n...\n...\nR0t3zU4iQUI=\n-----END CERTIFICATE-----\n&lt;\/cert&gt;\n&lt;key&gt;\n-----BEGIN PRIVATE KEY-----\nMIIEuwIBADANBgkqhkiG9w0BAQEFAASCBKUwggShAgEAAoIBAQCjLpmys21XpOW+\n...\n...\n3taMnSk389XsOUF6eZgw\n-----END PRIVATE KEY-----\n&lt;\/key&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create OpenVPN GUI Scheduler Task<\/h3>\n\n\n\n<p>To ensure that you are prompted to enter your OpenVPN connection credentials every time you login to your Windows system, you need to create a basic scheduler task.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Launch Task Scheduler Wizard<\/h4>\n\n\n\n<p>To create a scheduler task for OpenVPN, open the Task Scheduler wizard by pressing the <strong>Windows<\/strong>&nbsp;logo&nbsp;<strong>key<\/strong> and type <strong><code>task scheduler<\/code><\/strong>.<\/p>\n\n\n\n<p>Click on <strong>Task Scheduler<\/strong> program to lauch it.<\/p>\n\n\n\n<p>You can as well launch the scheduler by pressing the <strong><strong>Windows<\/strong>&nbsp;Key +&nbsp;<strong>R<\/strong><\/strong> and typing <strong><code>taskschd.msc<\/code><\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1055\" height=\"492\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/launch-task-scheduler.png\" alt=\"\" class=\"wp-image-6538\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/launch-task-scheduler.png?v=1595963163 1055w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/launch-task-scheduler-768x358.png?v=1595963163 768w\" sizes=\"(max-width: 1055px) 100vw, 1055px\" \/><\/figure>\n\n\n\n<p>Click <strong>Ok<\/strong> to launch the Task Scheduler program.<\/p>\n\n\n\n<p>If prompted on whether you want to allow the program to make changes, click <strong>Yes<\/strong> to accept.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Create a Basic Task<\/h4>\n\n\n\n<p>To create a task that will launch the <strong><code>openvpn-gui<\/code><\/strong> program on logon, click <strong>Create Basic Task<\/strong> as highlighted in the screenshot below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"569\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/create-basic-task.png\" alt=\"\" class=\"wp-image-6537\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/create-basic-task.png?v=1595963118 800w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/create-basic-task-768x546.png?v=1595963118 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure><\/div>\n\n\n<p>This will launch a basic task wizard.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Set the Name of the Task<\/h4>\n\n\n\n<p>Set a preferred name of the task and a description, if you like.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"492\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/name-of-the-task.png\" alt=\"\" class=\"wp-image-6539\" title=\"\"><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">Define Task Trigger<\/h4>\n\n\n\n<p>Set the task to be triggered on logon, by selecting <strong>When I log on<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"704\" height=\"489\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/task-trigger.png\" alt=\"\" class=\"wp-image-6540\" title=\"\"><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">Define the Task Scheduler Action<\/h4>\n\n\n\n<p>Click Next to set the action that the task should perform on logon. In this case, we want it to launch an openvpn-gui.exe program and prompt user to enter OpenVPN authentication credentials, hence, select <strong>Start a program<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"708\" height=\"491\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/start-a-program.png\" alt=\"\" class=\"wp-image-6541\" title=\"\"><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">Specify the Program to Launch<\/h4>\n\n\n\n<p>Click Next to specify the program to launch. In this case, we will need to launch the <strong><code>openvpn-gui.exe<\/code><\/strong> program and ask it to open our OpenVPN client configuration file, <strong><code>kifarunix-demo-vpn.ovpn<\/code><\/strong>.<\/p>\n\n\n\n<p>Specify the full path to the <strong><code>openvpn-gui.exe<\/code><\/strong>, which in our case is, <strong><code>C:\\Program Files\\OpenVPN\\bin\\openvpn-gui.exe<\/code><\/strong>.<\/p>\n\n\n\n<p>Note that our OpenVPN client configuration file, <strong><code>kifarunix-demo-vpn.ovpn<\/code><\/strong>, resides in the same directory as the <strong><code>openvpn-gui.exe<\/code><\/strong> program.<\/p>\n\n\n\n<p>Therefore, the arguments to pass to the program will be to tell it to connect to vpn using the client configuration file provided, <strong><code>--connect \"kifarunix-demo-vpn.ovpn\"<\/code><\/strong>.<\/p>\n\n\n\n<p><strong>Note the double quotes enclosing the client configuration file<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"704\" height=\"487\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/program-to-launch.png\" alt=\"\" class=\"wp-image-6542\" title=\"\"><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">Scheduled Task Summary<\/h4>\n\n\n\n<p>Click Next to check the summary of the scheduled task. To open the Task properties dialog when you finish the setup, check the box specified.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"697\" height=\"481\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/summary.png\" alt=\"\" class=\"wp-image-6543\" title=\"\"><\/figure><\/div>\n\n\n<p>Click <strong>Finish<\/strong> to proceed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Define the Task Privileges<\/h4>\n\n\n\n<p>Usually, connection to vpn requires elevated privileges. Hence, enable the task to run with highest privileges.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"637\" height=\"475\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/task-privs.png\" alt=\"\" class=\"wp-image-6544\" title=\"\"><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">Define the Task Conditions<\/h4>\n\n\n\n<p>From the task properties dialog, click <strong>Conditions<\/strong> tab and uncheck\/check the highlighted conditions.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"636\" height=\"480\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/task-conditions.png\" alt=\"\" class=\"wp-image-6545\" title=\"\"><\/figure><\/div>\n\n\n<h4 class=\"wp-block-heading\">Define the Task Settings<\/h4>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"639\" height=\"479\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/task-settings.png\" alt=\"\" class=\"wp-image-6546\" title=\"\"><\/figure><\/div>\n\n\n<p>Click <strong>Ok<\/strong> on the task dialog once you are done with the setup.<\/p>\n\n\n\n<p>You should now be able to see your task under <strong>Task Scheduler Library<\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Verify the Task Scheduler OpenVPN GUI Launch<\/h4>\n\n\n\n<p>Before you can restart your machine to verify  that you scheduled task works as expected, run the task program and its arguments on Command Prompt (CMD);<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\"C:\\Program Files\\OpenVPN\\bin\\openvpn-gui.exe\" --connect \"kifarunix-demo-vpn.ovpn\"<\/code><\/pre>\n\n\n\n<p>This should launch OpenVPN gui and prompt for OpenVPN username and password.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"816\" height=\"506\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/verify-task-program.png\" alt=\"\" class=\"wp-image-6547\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/verify-task-program.png?v=1595963623 816w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/verify-task-program-768x476.png?v=1595963623 768w\" sizes=\"(max-width: 816px) 100vw, 816px\" \/><\/figure>\n\n\n\n<p>Now, restart your machine to verify whether your program can be launched on logon.<\/p>\n\n\n\n<p>Upon logon, you should get the OpenVPN GUI prompt to enter your OpenVPN connection credentials.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"590\" height=\"383\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/logon-prompt.png\" alt=\"\" class=\"wp-image-6548\" title=\"\"><\/figure><\/div>\n\n\n<p>You can then verify that the task is running thereafter by navigating to Task Scheduler Library.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1825\" height=\"476\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/task-running.png\" alt=\"\" class=\"wp-image-6549\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/task-running.png?v=1595963675 1825w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/task-running-768x200.png?v=1595963675 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/07\/task-running-1536x401.png?v=1595963675 1536w\" sizes=\"(max-width: 1825px) 100vw, 1825px\" \/><\/figure>\n\n\n\n<p>You can as well verify the assigned IP address.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Related Tutorials<\/h3>\n\n\n\n<p><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/configure-openvpn-ldap-based-authentication\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure OpenVPN LDAP Based Authentication<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/kifarunix.com\/how-to-configure-ipsec-vpn-using-strongswan-on-ubuntu-18-04\/\" target=\"_blank\">Configure IPSEC VPN using StrongSwan on Ubuntu 18.04<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/configure-strongswan-vpn-client-on-ubuntu-18-04-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure strongSwan VPN Client on Ubuntu 18.04\/CentOS 8<\/a><\/p>\n\n\n\n<p><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/connect-to-vpn-automatically-on-ubuntu-20-04-18-04\/\" target=\"_blank\" rel=\"noreferrer noopener\">Connect to VPN Automatically on Ubuntu 20.04\/18.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to our tutorial on how to configure OpenVPN to prompt for credentials on logon on Windows systems. In most cases, you may want to<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,282],"tags":[1846,1845,283,1847,1848,909],"class_list":["post-6522","post","type-post","status-publish","format-standard","hentry","category-howtos","category-openvpn","tag-auto-start-openvpn-on-windows-system","tag-autoconnect-to-openvpn-on-windows-systems","tag-openvpn","tag-openvpn-prompt-for-credentials-on-login","tag-openvpn-windows-system","tag-windows-system","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/6522"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=6522"}],"version-history":[{"count":8,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/6522\/revisions"}],"predecessor-version":[{"id":21441,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/6522\/revisions\/21441"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=6522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=6522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=6522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}