泰山神 发表于 2019-1-26 15:33:00

搭建基于用户密码认证的Open***

  一、部署准备
  部署情况请查看我上一篇文章,我们这里只是针对上一篇文章进行简单的修改

  http://wzlinux.blog.运维网.com/8021085/1673778
  二、修改服务端
  # 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脚本:可以去官网下载也可以在我的附件里面下载
  http://open***.se/files/other/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 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 1chmod +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***
client
dev tun
proto tcp
remote 211.152.x.x 1194
nobind
user nobody
group nobody
persist-key
persist-tun
ca ca.crt
;cert client.crt
;key client.key
comp-lzo
verb 3
auth-user-pass             #客户端使用账号密码登录
reneg-sec 360000http://s3.运维网.com/wyfs02/M02/6F/C3/wKiom1WnYBrgqo1YAAFAtDBYmWs019.jpg
  直接输入帐号test1,test1登录就可以了。
  可以去/var/log/open***目录下面去查看运行日志等等信息,默认open***-password.log记录用户的登录信息,用户登录失败会记录下登录失败的密码。


附件:http://down.运维网.com/data/2367080

页: [1]
查看完整版本: 搭建基于用户密码认证的Open***