配置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-name

三:下載驗證用戶登錄腳本並進行相應的修改,主要改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***啓動用戶可讀取該文件

  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-pass

六:測試,若輸入錯誤的用戶名或密碼,則提示重新輸入用戶名和密碼,嘗試3次後中斷;

 

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章