theonemule / simple-openvpn-server

A setup script and simple web UI for setting up an OpenVPN Server
MIT License
232 stars 115 forks source link

Feature Request: build a script for Windows server #21

Closed MrSaeid007 closed 6 months ago

MrSaeid007 commented 1 year ago

Hi.

Can you guys build a simple web UI for Windows server users too to set up OpenVPN in the Windows server?

Thanks.

MrSaeid007 commented 1 year ago

This step may help.

!/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'"

theonemule commented 6 months ago

This would require almost a full rewrite. The UI is based on shell scripting, so I am not sure how I would accomplish that. Use a Linux VM as an alternative.