一、服务端配置

1、改动openvpn的主配置文件,加入例如以下内容

[root@ttt openvpn]# cat /etc/openvpn/server.conf |more

#########auth password########

script-security 3                  ###--增加脚本处理,如用password验证

auth-user-pass-verify /etc/openvpn/checkpsw.sh via-env     ###指定仅仅用的认证脚本

client-cert-not-required       #####不请求客户的CA证书,使用User/Pass验证,假设同一时候启用证书和password认证,凝视掉该行

username-as-common-name   ###   使用客户提供的UserName作为Common Name



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

2、依照配置文件里的脚本路径放置checkpsw.sh

[root@ttt openvpn]# cat checkpsw.sh 

#!/bin/sh

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

# checkpsw.sh (C) 2004 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="/var/log/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 1

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 1

fi



if [ "${password}" = "${CORRECT_PASSWORD}" ]; then 

  echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> ${LOG_FILE}

  exit 0

fi



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

exit 1

3、赋予该脚本运行权限

[root@ttt  openvpn]# chmod +x checkpsw.sh

4、准备username和password认证文件,username和password用空格隔开,同一时候确保openvpn启动用户可读取该文件

[root@ttt openvpn]# cat psw-file 

client01 123456

client02 123456789

为了安全起见,将psw-file的权限尽量改小

[root@ttt openvpn]# chmod 400 psw-file

[root@ttt openvpn]# chown nobody.nobody psw-file

5、重新启动openvpn的服务进程

二、改动client的配置文件,加入以下一行

auth-user-pass

三、开启windowsclient,进行password认证

OPENVPN开启用户password认证的更多相关文章

  1. mongodb添加用户和认证

    Mongodb默认启动是不带认证,也没有账号,只要能连接上服务就可以对数据库进行各种操作,这样可不行.现在,我们得一步步开启使用用户和认证. 第一步,我们得定位到mongodb的安装目录.我本机的是C ...

  2. MongoDB用户权限认证

    关于用户的认证及权限 用户是跟着库创建的,在哪个库创建的什么权限的什么用户,只对此库有相应权限(除超级管理员以外). 官网文档:https://docs.mongodb.com/master/refe ...

  3. Docker Mongo数据库开启用户认证

    一.启动mongo容器的几种方式 #简化版 docker run --name mongo1 -p 21117:27017 -d mongo --noprealloc --smallfiles #自定 ...

  4. Mongo开启用户认证

      1. 介绍 由于mongodb默认没有设置密码访问,而且mongodb的访问权限设计,必须使用有权限的用户给每个库设置一个用户,才能使用,且2.X版本与3.X版本区别有点大,所以要注意以下几点. ...

  5. [svc]centos6上部署openvpn+gg二步认证

    最近又发现个新的vpn: wireguard 为了满足员工在家办公的需求.需要 openvpn+gg方案 在centos6上部署openvpn 参考 1.安装前准备 wget -O /etc/yum. ...

  6. emqtt 试用(五)emq 的用户密码认证

    MQTT 认证设置 EMQ 消息服务器认证由一系列认证插件(Plugin)提供,系统支持按用户名密码.ClientID 或匿名认证. 系统默认开启匿名认证(anonymous),通过加载认证插件可开启 ...

  7. 基于SpringSecurity和JWT的用户访问认证和授权

    发布时间:2018-12-03   技术:springsecurity+jwt+java+jpa+mysql+mysql workBench   概述 基于SpringSecurity和JWT的用户访 ...

  8. EMQ -- 用户密码认证

    emq 的用户密码认证 MQTT 认证设置 EMQ 消息服务器认证由一系列认证插件(Plugin)提供,系统支持按用户名密码.ClientID 或匿名认证. 系统默认开启匿名认证(anonymous) ...

  9. emqtt emq 的用户密码认证

    MQTT 认证设置 EMQ 消息服务器认证由一系列认证插件(Plugin)提供,系统支持按用户名密码.ClientID 或匿名认证. 系统默认开启匿名认证(anonymous),通过加载认证插件可开启 ...

随机推荐

  1. hdu1573-X问题

    http://acm.hdu.edu.cn/showproblem.php?pid=1573 中国剩余定理 #include<iostream> #include<cstdio> ...

  2. JAVA编程心得-JAVA实现CRC-CCITT(XMODEM)算法

    CRC即循环冗余校验码(Cyclic Redundancy Check):是数据通信领域中最常用的一种差错校验码,其特征是信息字段和校验字段的长度可以任意选定. 1 byte checksum CRC ...

  3. 【剑指offer】和为定值的两个数

    转载请注明出处:http://blog.csdn.net/ns_code/article/details/24933341 题目描写叙述: 输入一个递增排序的数组和一个数字S,在数组中查找两个数,是的 ...

  4. hdu 1530 Maximum Clique

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1530 题目分类:最大团问题 DP + DFS 代码: #include<bits/stdc++. ...

  5. C++中的#pragma 预处理指令详解

    源地址:http://blog.csdn.net/roger_77/article/details/660311 在所有的预处理指令中,#pragma 指令可能是最复杂的了,它的作用是设定编译器的状态 ...

  6. Iconfinder 如何杜绝盗版,哈希算法检测图像重复

    原地址:http://blog.jobbole.com/65914/ 本文由 伯乐在线 - 小鱼 翻译自 Silviu Tantos.欢迎加入技术翻译小组.转载请参见文章末尾处的要求. [伯乐在线导读 ...

  7. js关闭浏览器窗口事件

    js关闭浏览器窗口 js关闭浏览器窗口,不弹出提示框.支持ie6+,火狐,谷歌等浏览器. <html> <head /> <body> <script typ ...

  8. expdp时遇到ORA-31693&amp;ORA-02354&amp;ORA-01466

    expdp时遇到ORA-31693&ORA-02354&ORA-01466 对一个schema运行expdp导出,expdp命令: nohup expdp HQ_X1/HQ_X1 DU ...

  9. selenium让人摸不着头脑的问题

    selenium让人摸不着头脑的问题 问题一 使用webdriver驱动firefox浏览器时如果不设置参数,默认使用的Firefox的profile和平时打开浏览器使用的firefox不一样,如果要 ...

  10. random_shuffle (stl算法)打乱顺序 - 飞不会的日志 - 网易博客

    random_shuffle (stl算法)打乱顺序 - 飞不会的日志 - 网易博客 random_shuffle (stl算法)打乱顺序 2012-03-31 10:39:11|  分类: 算法 | ...