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兩個變量測試
- # cd /usr/local/open***/etc/
- # wget http://open***.se/files/other/checkpsw.sh
- # chmod +x checkpsw.sh
- # cat 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="/usr/local/open***/etc/psw-file"
- LOG_FILE="/usr/local/open***/var/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
四:準備用戶名和密碼認證文件,用戶名和密碼用空格隔開,同時確保open***啓動用戶可讀取該文件ui
- # cat psw-file
- yangliangwei 123456
- # chmod 400 psw-file
- # 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