1、安装open***
这里不详细些如何安装部署open***了,具体部署参考前面的博文。
2、配置通过本地文件认证
#server.conf参数说明
auth-user-pass-verify /etc/open***/checkpsw.sh via-env
client-cert-not-required #表示不请求客户的证书,使用user/pass 认证
username-as-common-name #表示客户端认证时候需要用户名
===============
cat >>/etc/open***/server.conf<<eof
auth-user-pass-verify /etc/open***/checkpsw.sh via-env
client-cert-not-required
username-as-common-name
#script-security 3 #注意2.0.6版本没有这个参数。如果是2.2.2版本的要多加这一个参数
eof
################################
################################
参数说明:
auth-user-pass-verify /etc/open***/checkpsw.sh via-env
#通过后面的/etc/open***/checkpsw.sh命令和via-env的方法进行验证
#如果使用via-env方法,那么就通过用户名/密码进行验证,如果用via-file。那么就通过临时文件验证
client-cert-not-required
#不请求用户证书。使用用户名/密码验证
username-as-common-name
#使用客户端提供用户名作为common Name
提示:/etc/open***/checkpsw.sh是shell脚本,用来接收***客户端的用户和密码,和本地文件进行对比验证,通过返回值确认是否可以连接×××,返回1就是失败,返回0是成功
################################
追加到server.conf里面
tail -3 /etc/open***/server.conf
具体配置文件如下
################################
[root@L××× open***]# cat server.conf
local 10.0.0.3
port 52115
proto tcp
dev tun
ca /etc/open***/keys/ca.crt
cert /etc/open***/keys/server.crt
key /etc/open***/keys/server.key
dh /etc/open***/keys/dh1024.pem
server 11.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "route 192.168.2.0 255.255.255.0"
client-to-client
keepalive 10 120
comp-lzo
persist-key
persist-tun
status /etc/open***/open***-status.log
verb 3
log /etc/open***/open***.log
####add
auth-user-pass-verify /etc/open***/checkpsw.sh via-env
client-cert-not-required
username-as-common-name
[root@L××× open***]#
###################################
获取checkpsw.sh脚本
wget -q -P /etc/open***/ http://open***.se/files/other/checkpsw.sh
脚本内容如下:
#!/bin/sh
###########################################################
# checkpsw.sh (C) 2004 Mathias Sundman <mathias@open***.se>
#
# 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***-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
#######################################
chmod +x /etc/open***/checkpsw.sh
ls -l /etc/open***/checkpsw.sh
#######################################
创建密码文件
cat >>/etc/open***/psw-file<<eof
oldboy 111111
test 111111
eof
chmod 400 /etc/open***/psw-file
修改客户端配置文件
注释掉
;cert gao.crt
;key gao.key
增加询问用户名和密码
auth-user-pass
修改后的配置文件
##################################
client
dev tun
proto tcp
remote 10.0.0.4 52115 #这里是服务端的IP和***服务的端口
resolv-retry infinite
nobind
persist-key
persist-tun
ns-cert-type server
ca ca.crt #这里是当前用户的ca证书
#cert gao.crt #这里是当前用户的ca证书
#key gao.key #这里是当前用户的ca证书
comp-lzo
verb 3
auth-user-pass
########################################
用客户端登录即可。注意有些下载的checkpsw.sh 不可用,可以用上面的
转载于:https://blog.51cto.com/lvnian/1708851