一、部署準備
部署情況請查看我上一篇文章,我們這裏只是針對上一篇文章進行簡單的修改
http://wzlinux.blog.51cto.com/8021085/1673778
二、修改服務端
# vim /etc/open***/server.conf
在配置文件最後面添加如下幾行數據
script-security 3 system #允許通過環境變量將密碼傳遞給腳本 auth-user-pass-verify /etc/open***/checkpsw.sh via-env #提供一個用戶名密碼對 client-cert-not-required #不使用客戶端證書,使用密碼對 username-as-common-name #使用認證用戶名,不使用證書的common name
創建checkpsw.sh腳本:可以去官網下載也可以在我的附件裏面下載
http://open***.se/files/other/checkpsw.sh
# cd /etc/open***
# vim 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***/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 checkpsw.sh
創建psw-file文件:
cd /etc/open*** echo "test1 test1" > psw-file #創建賬號密碼,可以多行,每行一組 chmod 400 psw-file #修改文件權限,我是用root權限執行的
加入開機啓動項:
chkconfig open*** on
重啓open***服務端:
service open*** start
三、修改客戶端
客戶端以windows爲例:
客戶端操作步驟,具體可以查看我上一篇文章裏面的安裝步驟。
下載windows客戶端:
http://open***.ustc.edu.cn/open***-install-2.3.6-I603-x86_64.exe
安裝好客戶端軟件之後,把之前從服務端打包的客戶端需要的證書解壓到客戶端安裝目錄下的config目錄中。
並且創建客戶端配置文件:
打開client.o***
client dev tun proto tcp remote 211.152.x.x 1194 nobind user nobody group nobody persist-key persist-tun ca ca.crt ;cert client.crt ;key client.key comp-lzo verb 3 auth-user-pass #客戶端使用賬號密碼登錄 reneg-sec 360000
直接輸入帳號test1,test1登錄就可以了。
可以去/var/log/open***目錄下面去查看運行日誌等等信息,默認open***-password.log記錄用戶的登錄信息,用戶登錄失敗會記錄下登錄失敗的密碼。