本文共 2322 字,大约阅读时间需要 7 分钟。
一、部署准备
部署情况请查看我上一篇文章,我们这里只是针对上一篇文章进行简单的修改
二、修改服务端
# vim /etc/open***/server.conf
在配置文件最后面添加如下几行数据
script-security 3 system #允许通过环境变量将密码传递给脚本 auth-user-pass-verify /etc/open***/checkpsw.sh via-env #提供一个用户名密码对client-cert-not-required #不使用客户端证书,使用密码对username-as-common-name #使用认证用户名,不使用证书的common name
创建checkpsw.sh脚本:可以去官网下载也可以在我的附件里面下载
# cd /etc/open***
# vim checkpsw.sh
#!/bin/sh############################################################ checkpsw.sh (C) 2004 Mathias Sundman## This script will authenticate Open*** 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/open***/psw-file"LOG_FILE="/var/log/open***/open***-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 1fi 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 1fi if [ "${password}" = "${CORRECT_PASSWORD}" ]; then echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> ${LOG_FILE} exit 0fi echo "${TIME_STAMP}: Incorrect password: username=\"${username}\", password=\"${password}\"." >> ${LOG_FILE}exit 1
chmod +x checkpsw.sh
创建psw-file文件:
cd /etc/open***echo "test1 test1" > psw-file #创建账号密码,可以多行,每行一组chmod 400 psw-file #修改文件权限,我是用root权限执行的
加入开机启动项:
chkconfig open*** on
重启open***服务端:
service open*** start
三、修改客户端
客户端以windows为例:
客户端操作步骤,具体可以查看我上一篇文章里面的安装步骤。
下载windows客户端:
http://open***.ustc.edu.cn/open***-install-2.3.6-I603-x86_64.exe
安装好客户端软件之后,把之前从服务端打包的客户端需要的证书解压到客户端安装目录下的config目录中。
并且创建客户端配置文件:
打开client.o***
clientdev tunproto tcpremote 211.152.x.x 1194nobinduser nobodygroup nobodypersist-keypersist-tunca ca.crt;cert client.crt;key client.keycomp-lzoverb 3auth-user-pass #客户端使用账号密码登录reneg-sec 360000
直接输入帐号test1,test1登录就可以了。
可以去/var/log/open***目录下面去查看运行日志等等信息,默认open***-password.log记录用户的登录信息,用户登录失败会记录下登录失败的密码。
转载地址:http://wmyel.baihongyu.com/