配置Open×××使用User/Pass方式验证登陆

Open***和PPTP ×××相比存在诸多的优点,最明显的是Open***支持NAT穿越,也就是说在nat环境下使用open***只须要一个在路由器上作一个端口映射便可!不须要其余路由的支持,要知道不是全部的路由器都支持配置NAT穿越,只有高级的路由器才提供这种功能!其次open***使用证书加密数据传输,安全性方便也优于PPTP ×××,但在配置方面比PPTP ×××要复杂许多!并且open***客户端登陆只须要双击就能够链接服务器端,从感官上反而以为安全性低,于是下面介绍下open***使用user/pass方式用户验证登陆,使用这种方式验证用户登陆在注销用户帐号的时候只要删除密码文件中的记录便可,很是的方便!安全

一:在开始以前请先配置配置好open***服务器和客户端,可参考如下安装文档!
http://hi.baidu.com/naruto6006/item/74dfe5b471298370254b09af 服务器

二:修改open***服务主配置文件,添加以下内容;若是加上client-cert-not-required则表明只使用用户名密码方式验证登陆,若是不加,则表明须要证书和用户名密码双重验证登陆!
# tail -3 /usr/local/open***/etc/server.conf
auth-user-pass-verify /usr/local/open***/etc/checkpsw.sh via-env
client-cert-not-required 
username-as-common-nameide

三:下载验证用户登陆脚本并进行相应的修改,主要改PASSFILE和LOG_FILE两个变量测试

  
  
           
  
  
  1. # cd /usr/local/open***/etc/  
  2. # wget http://open***.se/files/other/checkpsw.sh  
  3. # chmod +x checkpsw.sh  
  4. # cat checkpsw.sh   
  5. #!/bin/sh  
  6. ###########################################################  
  7. # checkpsw.sh (C) 2004 Mathias Sundman <mathias@open***.se> 
  8. #  
  9. # This script will authenticate Open××× users against  
  10. # a plain text file. The passfile should simply contain  
  11. # one row per user with the username first followed by  
  12. # one or more space(s) or tab(s) and then the password.  
  13.  
  14. PASSFILE="/usr/local/open***/etc/psw-file" 
  15. LOG_FILE="/usr/local/open***/var/open***-password.log" 
  16. TIME_STAMP=`date "+%Y-%m-%d %T"`  
  17.  
  18. ###########################################################  
  19.  
  20. if [ ! -r "${PASSFILE}" ]; then  
  21.   echo "${TIME_STAMP}: Could not open password file \"${PASSFILE}\" for reading." >>   
  22.  
  23. ${LOG_FILE}  
  24.   exit 1  
  25. fi  
  26.  
  27. CORRECT_PASSWORD=`awk '!/^;/&&!/^#/&&$1=="'${username}'"{print $2;exit}' ${PASSFILE}`  
  28.  
  29. if [ "${CORRECT_PASSWORD}" = "" ]; then   
  30.   echo "${TIME_STAMP}: User does not exist: username=\"${username}\", password=  
  31.  
  32. \"${password}\"." >> ${LOG_FILE}  
  33.   exit 1  
  34. fi  
  35.  
  36. if [ "${password}" = "${CORRECT_PASSWORD}" ]; then   
  37.   echo "${TIME_STAMP}: Successful authentication: username=\"${username}\"." >> ${LOG_FILE}  
  38.   exit 0  
  39. fi  
  40.  
  41. echo "${TIME_STAMP}: Incorrect password: username=\"${username}\", password=  
  42.  
  43. \"${password}\"." >> ${LOG_FILE}  
  44. exit 1 

四:准备用户名和密码认证文件,用户名和密码用空格隔开,同时确保open***启动用户可读取该文件ui

  
  
           
  
  
  1. # cat psw-file   
  2. yangliangwei 123456  
  3.  
  4. # chmod 400 psw-file  
  5. # chown nobody.nobody psw-file 

五:修改客户端配置文件
注释掉
;cert yangliangwei.crt 
;key  yangliangwei.key加密

增长询问用户名和密码   
auth-user-passspa

六:测试,若输入错误的用户名或密码,则提示从新输入用户名和密码,尝试3次后中断;server

 

# tail -f /usr/local/open***/var/open***-password.log
2012-09-28 09:41:13: Successful authentication: username="yangliangwei"xml

相关文章
相关标签/搜索