在openVPN服务器配置原来的基础上添加
修改server.ovpn文件
####open*** authenticated with user/pass
script-security 2
auth-user-pass-verify checkpsw.bat via-file
verify-client-cert none
username-as-common-name
checkpsw.bat
在server.ovpn同级目录添加checkpws.bat批处理文件
@echo off
setlocal enabledelayedexpansion
rem get username and password from temp file as %1
set v=1
for /f %%i in (%1) do (
if !v!==1 (
set USERNAME=%%i
set v=2
echo !USERNAME! >>file.txt
)else (
set PASSWORD=%%i
echo !PASSWORD! >>file.txt
)
)
rem check username and password with password.txt file
for /f "tokens=1,2,3 delims=," %%i in (password.txt) do if %%i == !USERNAME! if %%j==!PASSWORD! if %%k == 1 exit /B 0
exit /B 1
password.txt
用户名,密码,是否启用(1是0否)
aaa,111111,1
bbb,222222,1