架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 9964|回复: 4

[VPN] 搭建 OpenVPN Server 路由模式 + 口令认证+TEXT/POP3

[复制链接]
发表于 2015-9-17 19:34:21 | 显示全部楼层 |阅读模式
目的:客户端还是连接到公司局域网中,但为了用户管理方便,认证数据从 TEXT 数

据库中提取。

OpenVPN Server 基本设定:连接方式采用路由,认证方式采用 TEXT/POP3 认证,虚

拟设备使用 tun



1. 下载 TEXT 认证脚本 checkpsw.sh ,并且复制到 /usr/local/etc/ 目录中同时 chmod u+x 。

http://openvpn.se/files/other/

注意: 1.脚本保存到 windows 中再上传导 linux 有问题,最好在那个目录新建一个同名

文件再从控制台粘贴进去。

2.脚本的开始不是 #! 要改正。



2.配置服务器配置文件, 在(一)的基础上



添加如下几行:

# auth-user-pass-verify cmd method: Query client for username/password and

# run scrip{过滤}t cmd to verify.     If method=’via-env’, pass

# user/pass via environment, if method=’via-file’, pass

# user/pass via temporary file.

auth-user-pass-verify /usr/local/etcfile:///C:\Users\lenovo\AppData\Local\Temp\)QN1UH78VKP2T7)IA]ZM(FW.gifeckpsw.sh via-env

#不请求客户的CA证书,使用User/Pass验证

client-cert-not-required

#使用客户提供的UserName作为Common Name

username-as-common-name

3..配置客户端配置文件

注释掉

;cert client1.crt

;key client1.key

增加

#询问用户名和密码

auth-user-pass



4.更改 checkpsw.sh 中的 PASSFILE 变量为。

PASSFILE=”/usr/local/etc/psw-file”

5. 创建 /usr/local/etc/psw-file 内容如下:

格式:用户名 Tab 密码

User1        pass

User2        pass

注:实验成功后我自己仿照 checkpsw.sh 用 perl 重写了一遍(目录中的 checkpsw.pl),也

可以使用。

6.同样的原理我们还可以使用 POP3 认证(^_^ 其他的当然也可以)

脚本见目录中的 popauth.pl





(五) 搭建 OpenVPN Server 路由模式 + 口令认证+RADIUS

网络环境:在(一)的基础上添加一台 win2003 服务器 ip 为 192.168.80.130

^_^ 不好意思,我把服务器给放到了公网上了。不过还好是测试。

目的:客户端还是连接到公司局域网中,但为了用户管理方便,认证数据从 radius 数

据库中提取。

OpenVPN Server 基本设定:连接方式采用路由,认证方式采用 radius 认证,虚拟设备

使用 tun



1. 搭建 Radius 服务器

见附录 搭建 win2003 下的 IAS 服务

2. 配置 radiusplugin

1.radiusplugin_v2.0.tar.gz: 可以编译得到 radiusplugin.so

到 http://www.nongnu.org/radiusplugin/下载

2.libgcrypt 支持库: 可以编译得到/usr[img]file:///C:\Users\lenovo\AppData\Local\Temp\)A[Y)I~](ZC9Z[3Y)IDK7LK.gif[/img]b[img]file:///C:\Users\lenovo\AppData\Local\Temp\)A[Y)I~](ZC9Z[3Y)IDK7LK.gif[/img]bgcrypt.so.11

到 ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.2.4.tar.gz 下载

3.libgpg-error 支持库: 可以编译得到/usr/local[img]file:///C:\Users\lenovo\AppData\Local\Temp\)A[Y)I~](ZC9Z[3Y)IDK7LK.gif[/img]b[img]file:///C:\Users\lenovo\AppData\Local\Temp\)A[Y)I~](ZC9Z[3Y)IDK7LK.gif[/img]bgpg-error.so.0

到 ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.5.tar.gz 下载

简单的编译以上 3 个支持库,configure;make;make install。

我们要用到 radiusplugin.so,其他是 radiusplugin.so 的支持库。

好了如果能够得到 radiusplugin.so,已经成功了 80%,其他的就是配置了。

把 radiusplugin.so 拷贝到/usr/local/etc[img]file:///C:\Users\lenovo\AppData\Local\Temp\)A[Y)I~](ZC9Z[3Y)IDK7LK.gif[/img]b 下,并配置其配置文件 radiusplugin.conf

内容如下:

# The NAS identifier which is sent to the RADIUS server
NAS-Identifier=OpenVpn

# The service type which is sent to the RADIUS server

Service-Type=5

# The framed protocol which is sent to the RADIUS server

Framed-Protocol=1

# The NAS port type which is sent to the RADIUS server

NAS-Port-Type=5

# 这是运行 openvpn 服务器的 ip,作为 radius 客户端

NAS-IP-Address=192.168.80.129

#这里指明 openvpn 的配置位置

OpenVPNConfig=/usr/local/etcfile:///C:\Users\lenovo\AppData\Local\Temp\V7(XMWRN]{G8~CI}BCCR3QC.gifrver.conf

# 这里定义 radius server 参数可以超过 1 个作为备份

server
{

# The UDP port for radius accounting.

acctport=1813

# The UDP port for radius authentication.

authport=1812

# 这是我 radius 服务器的 ip,并添加了用户。

name=192.168.80.130



# How many times should the plugin send the if there is no response?

retry=1

# How long should the plugin wait for a response?

wait=1

# The shared secret.共享密钥,在 winradius 里配置,设置-系统-NAS 密钥

sharedsecret=123456

}



3.配置服务器配置文件, 在(一)的基础上



添加如下几行:

#说明使用的插件

plugin /usr/local/etc[img]file:///C:\Users\lenovo\AppData\Local\Temp\)A[Y)I~](ZC9Z[3Y)IDK7LK.gif[/img]b/radiusplugin.so /usr/local/etc/radius.conf

#不请求客户的CA证书,使用User/Pass验证

client-cert-not-required

#使用客户提供的UserName作为Common Name

username-as-common-name

4.配置客户端配置文件

注释掉

;cert client1.crt

;key client1.key

增加

#询问用户名和密码

auth-user-pass





上一篇:无题
下一篇:【原创】”\u"开头的Unicode加密解密工具
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
发表于 2015-9-22 02:55:31 | 显示全部楼层
不管能不能用先回复看看
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
发表于 2017-2-26 11:18:54 | 显示全部楼层
支持下鼓励
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
发表于 2018-10-22 14:09:08 | 显示全部楼层
您好,我这个有些问题,您可以帮忙弄一下吗
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
发表于 2018-10-22 23:37:40 | 显示全部楼层
学习一下
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2024-3-29 01:33

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表