openvpn-install icon indicating copy to clipboard operation
openvpn-install copied to clipboard

Feuture request: Create a script for windows server to setup openvpn server

Open MrSaeid007 opened this issue 1 year ago • 1 comments

Hi guys.

Can you guys create a script on your official GitHub page to set up the OpenVPN server on the Windows server too?

Thanks.

MrSaeid007 avatar Jul 26 '23 08:07 MrSaeid007

Something like this we need to run on our Windows server and automatically create a username and... like what we have on Linux Script.

#!/bin/bash

Define the URLs for the OpenVPN installer and the Easy-RSA ZIP archive

openvpnInstallerUrl="https://openvpn.net/community-downloads/" easyRsaZipUrl="https://github.com/OpenVPN/easy-rsa-old/archive/refs/tags/v2.3.3.zip"

Set up temporary directories for the installer and Easy-RSA

tmpDir=$(mktemp -d) openvpnInstallerPath="$tmpDir/openvpn-install.exe" easyRsaZipPath="$tmpDir/easy-rsa.zip" easyRsaDir="$tmpDir/easy-rsa"

Download the OpenVPN installer and Easy-RSA ZIP archive

curl -L -o "$openvpnInstallerPath" "$openvpnInstallerUrl" curl -L -o "$easyRsaZipPath" "$easyRsaZipUrl"

Install OpenVPN silently with default options

cmd.exe /C "$openvpnInstallerPath /S"

Extract the Easy-RSA ZIP archive

unzip -q "$easyRsaZipPath" -d "$tmpDir"

Move the Easy-RSA directory to the OpenVPN installation folder

mv "$tmpDir/easy-rsa-old-2.3.3" "/c/Program Files/OpenVPN/easy-rsa"

Navigate to the Easy-RSA directory

cd "/c/Program Files/OpenVPN/easy-rsa"

Run the initialization script to set environment variables

cmd.exe /C "vars.bat"

Clean any existing keys

cmd.exe /C "clean-all"

Build the Certificate Authority (CA)

cmd.exe /C "build-ca"

Generate the server key and certificate

cmd.exe /C "build-key-server your_server_name"

Generate Diffie-Hellman parameters (used for key exchange)

cmd.exe /C "build-dh"

Replace 'C:\path\to\server.ovpn' with the actual path to your server configuration file

serverConfigPath="C:\path\to\server.ovpn"

Copy the server configuration file to the config directory

cp "$serverConfigPath" "/c/Program Files/OpenVPN/config/"

Start the OpenVPN service

cmd.exe /C "openvpn-gui --command connect 'your_server_name'"

MrSaeid007 avatar Jul 26 '23 08:07 MrSaeid007