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兩個變量
# 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***啓動用戶可讀取該文件
# cat psw-file yangliangwei 123456 # chmod 400 psw-file # 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"