wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh

https://github.com/Nyr/openvpn-install

1.修改配置文件。(添加下列配置)

script-security 3                         #加入script-security消除以下警告  不是很了解,不加拨号失败(允许OPenvpn使用用户自动以脚本)
client-cert-not-required                  #取消客户端的证书认证  如果双重验证注释掉此行,客户端配置文件证书路径保留。
username-as-common-name
auth-user-pass-verify /etc/openvpn/checkpsw.sh via-env             #开启用户密码脚本

2.添加验证脚本,密码文件。

验证脚本

# vi checkpsw.sh

#!/bin/sh
###########################################################
# checkpsw.sh (C)  Mathias Sundman <mathias@openvpn.se>
#
# This script will authenticate OpenVPN users against
# a plain text file. The passfile should simply contain
# one row per user with the username first followed by
# one or more space(s) or tab(s) and then the password.

PASSFILE="/etc/openvpn/psw-file"
LOG_FILE="/etc/openvpn/openvpn-password.log"
TIME_STAMP=`date "+%Y-%m-%d %T"`

###########################################################

if [ ! -r "${PASSFILE}" ]; then
  echo "${TIME_STAMP}: Could not open password file \"${PASSFILE}\" for reading." >> ${LOG_FILE}
  exit
fi

CORRECT_PASSWORD=`awk '!/^;/&&!/^#/&&$1=="'${username}'"{print $2;exit}' ${PASSFILE}`

if [ "${CORRECT_PASSWORD}" = "" ]; then
  echo "${TIME_STAMP}: User does not exist: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE}
  exit
fi

if [ "${password}" = "${CORRECT_PASSWORD}" ]; then
  echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> ${LOG_FILE}
  exit
fi

echo "${TIME_STAMP}: Incorrect password: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE}
exit 

添加脚本可执行权限

# chmod +x checkpsw.sh

密码验证文件

# vi psw-file

psw-file中一行是一个账号,用户名和密码之间用空格隔开

添加文件可读取权限

# chmod 400 checkpsw.sh

3.设置客户端

注销掉这两行

#cert peara.crt

#key peara.key

再添加这一行,添加这行,就会提示输入用户名和密码

auth-user-pass

4.重启服务

参考博客:

openVPN本地密码验证

https://www.cnblogs.com/sunpear/p/5722482.html

openVPN设置本地密码验证的更多相关文章

  1. SQL Server设置登录验证模式

    我们在安装SQL Server的时候可以设置“混合验证模式”,既可以使用windows身份验证登录,也可以使用SQL Server身份验证登录. 如果我们在安装的时候并未设置"混合验证模式& ...

  2. C# 设置或验证 PDF中的文本域格式

    概述 PDF中的文本域可以通过设置不同格式,用于显示数字.货币.日期.时间.邮政编码.电话号码和社保号等等.Adobe Acrobat提供了许多固定的JavaScripts用来设置和验证文本域的格式, ...

  3. Openvpn 本地密码验证

    1.修改配置文件.(添加下列配置) auth-user-pass-verify /etc/openvpn/checkpsw.sh via-env #开启用户密码脚本 client-cert-not-r ...

  4. 使用nginx代理kibana并设置身份验证

    1.在es-sever上安装nginx #wget http://nginx.org/download/nginx-1.8.1.tar.gz #tar xvf nginx-1.8.1.tar.gz # ...

  5. 通过批处理 安装 mongodb和设置身份验证

    1.首先需要 mongodb.msi安装包 2.mongodb的配置文件mongod.cfg 内容如下: systemLog: destination: file path: "D:/mon ...

  6. Nginx设置身份验证

    在某些情况下,需要对某些内容的访问进行限制,在Nginx中也提供了这样的限制措施,以下是几种常见的限制措施: 1.访问身份验证 在Nginx的插件模块中有一个模块ngx_http_auth_basic ...

  7. OpenVPN设置客户端固定IP

    在使用openvpn的过程中,多台客户端连接上同一台openvpn服务器之后,客户端的的IP地扯经常变动,导致客户端之间无法正常通讯,openvpn的版本变动也导致了固定IP地扯的配置不同,用以下方法 ...

  8. PHP设置谷歌验证器(Google Authenticator)实现操作二步验证

    使用说明:开启Google的登陆二步验证(即Google Authenticator服务)后用户登陆时需要输入额外由手机客户端生成的一次性密码.实现Google Authenticator功能需要服务 ...

  9. 1.设置和验证MySQL数据库的隔离级别

    登录数据库 mysql -u root - p 新建用户,各启动一个事物,用于同时操作数据库表中数据 create user tom identified by 'tom'; 然后同时再用该用户启动M ...

随机推荐

  1. 【BZOJ1497】【NOI2006】最大获利

    最小割好劲啊 原题: 新的技术正冲击着手机通讯市场,对于各大运营商来说,这既是机遇,更是挑战.THU集团旗下的CS&T通讯公司在新一代通讯技术血战的前夜,需要做太多的准备工作,仅就站址选择一项 ...

  2. Server 2008 R2部署active directory服务器-ad域

    一.部署AD域: 系统环境:Windows server 2008 R2 标准版 ip:172.16.1.149服务器开机后会自动弹出一个初始配置任务窗口(这个不要随便关闭,因为我不知道关闭后能在哪里 ...

  3. Connecting Elixir Nodes with libcluster, locally and on Kubernetes

    转自:https://www.poeticoding.com/connecting-elixir-nodes-with-libcluster-locally-and-on-kubernetes/ Tr ...

  4. sqler sql 转rest api 的工具试用

    sqler 从开源很快就获取了1k的star,使用起来很方便,而且也很灵活,支持的数据库也比较多. 支持的功能 无需依赖,可独立使用: 支持多种数据可类型,包括:SQL Server, MYSQL, ...

  5. Creating Node.js Command Line Utilities to Improve Your Workflow

    转自:https://developer.telerik.com/featured/creating-node-js-command-line-utilities-improve-workflow/ ...

  6. How To Use the AWK language to Manipulate Text in Linux

    https://www.digitalocean.com/community/tutorials/how-to-use-the-awk-language-to-manipulate-text-in-l ...

  7. Delphi中Json格式读写

    Json是一种轻量级传输数据格式,广泛应用互联网和各应用中.json主要採用键值对来表示数据项.多个数据项之间用逗号分隔,也能够用于数组.以下注重介绍一下在delphi中使用json,在delphi中 ...

  8. BackgroundWorker Class Sample for Beginners

    Download source - 27.27 KB Introduction This article presents a novice .NET developer to develop a m ...

  9. C#更新程序设计

    更新程序设计 大致设想了两种更新方式,如下所示: 一种简单暴力,直接请求静态资源服务器上的文件 第二种考虑了网络传输不稳定时,中断的情况.再次启动更新时会检测本地文件下载多少了,然后接着上次中断的位置 ...

  10. oracle参数文件与启动过程

    oracle随系统启动而启动 cs65-64桌面版orcle-11.2.0.4 启动监听器,后台进程,OEM. 注意: 如果只做一和三,只能启动后台进程,监听器不启动,如果只做二和三,只能启动监听器, ...