Skip to content

Automation tool for creating temporary OpenVPN profiles with credentials.

Notifications You must be signed in to change notification settings

astrixgame/openpvn-temp-profiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OpenVPN temp profile automation

A PowerShell tool for automatically creating and connecting temporary OpenVPN profiles. Credentials are stored in the Windows Registry and securely deleted after use.

πŸ§‘πŸ»β€πŸ’» Usage

Define profile name and credentials

SetAndRun.ps1: Sets up credentials and starts VPN

$profile = "<profile name>"
$username = "<auth username>"
$authpwd = "<auth password>"
$privpwd = "<private key password>"

GetStatus.ps1: Returns connection state of selected VPN profile, works only for TCP VPN profiles

$profile = "<profile name>"

GetCreds.ps1: Returns vpn credentials of all VPN profiles

To start PS script in background you can use:
powershell -windowstyle hidden -file C:\some\path\to\SetAndStart.ps1

πŸ›  Additional options/parts

Copy downloaded OVPN profile:

$downloadpath = "C:\Users\$currentuser\Downloads\$profile.ovpn"
...
Copy-Item $downloadpath -Destination "C:\Users\$currentuser\OpenVPN\config"

Start OpenVPN GUI with connect parameter:

Start-Process -FilePath "C:\Program Files\OpenVPN\bin\openvpn-gui.exe" -ArgumentList "--connect $profile.ovpn"

Wait for OpenVPN to connect:

πŸ’‘ This delay is important: without enabling silent connection mode in OpenVPN GUI, the connection dialog pauses for 5 seconds waiting for user confirmation β€” plus additional time for the actual connection to establish.

Start-Sleep -Seconds 8

Remove credentials from registry:

Remove-Item -Path "$regPath\" -Recurse

Setup silent connection (OpenVPN GUI)

Right click on tray icon and click on settings, in General tab check the Silent connection Image

πŸ› οΈ Tech Stack

About

Automation tool for creating temporary OpenVPN profiles with credentials.

Topics

Resources

Stars

Watchers

Forks