一服務器環境mysql
一、系統版本sql
CentOS release 5.10 (Final) 64bitswindows
二、軟件版本api
open***-2.3.6-1.el5bash
lzo-2.02-2.el5.1服務器
lzo-devel-2.02-2.el5.1app
easy-rsa-2.2.2-1.el5tcp
pam-0.99.6.2-12.el5ide
pam-devel-0.99.6.2-12.el5測試
二配置服務器安裝前環境
一、打開ip轉發功能
echo "net.ipv4.ip_forward = 1">> /etc/sysctl.conf sysctl -p
二、安裝依賴及所需軟件包
yum install -y open*** easy-rsa cyrus-saslcyrus-sasl-plain cyrus-sasl-devel cyrus-sasl-lib cyrus-sasl-gssapi pampam-devel /etc/init.d/saslauthd restart
三、修改變量及生成證書
cd /usr/share/easy-rsa/2.0 vi vars #編輯vars文件,生成環境變量, vars裏的參數根據本身須要改變 export KEY_COUNTRY="CN" #定義你所在的國家2個字符 export KEY_PROVINCE="ShangHai" #你所在的省份 export KEY_CITY="ShangHai" #你所在的城市 export KEY_ORG="xxx" #你所在的組織 export KEY_EMAIL="xxx@qq.com" #你的郵件地址能夠修改 source ./vars ./clean-all ./build-ca ./build-dh ./build-key-server server ./build-key client #tar -zcvf client.tar.gz keys/{ca.crt,client.crt,client.key} #windows客戶端使用需下載到本地 mkdir /etc/open***/{keys,logs,plugin/auth-pam} -p cp /usr/share/easy-rsa/2.0/keys/{ca.crt,server.crt,server.key,dh2048.pem} /etc/open***/keys/ cat > /etc/open***/server.conf <<EOF port 443 proto tcp dev tun ca keys/ca.crt cert keys/server.crt key keys/server.key dh keys/dh2048.pem server 10.100.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt #添加主機路由 push "route 10.200.0.0 255.255.0.0" push "route 10.220.0.0 255.255.0.0" keepalive 10 120 comp-lzo user nobody group nobody persist-key persist-tun status logs/open***-status.log log logs/open***.log log-append logs/open***.log verb 3 plugin /etc/open***/plugin/open***-auth-pam.so open*** client-cert-not-required username-as-common-name EOF
四、使用低版本的認證插件
wget http://pkgs.fedoraproject.org/repo/pkgs/open***/open***-2.0.7.tar.gz/93528233f1f6d02fc18e2c00f82e0aca/open***-2.0.7.tar.gz tar xf open***-2.0.7.tar.gz cd open***-2.0.7/plugin/auth-pam make cp open***-auth-pam.so /etc/open***/plugin/ #這一步可能沒法成功假如沒法成功可從其餘機器拷貝一份過去我在附件中放了該文件 wget http://nchc.dl.sourceforge.net/project/pam-mysql/pam-mysql/0.7RC1/pam_mysql-0.7RC1.tar.gz tar xf pam_mysql-0.7RC1.tar.gz && cd pam_mysql-0.7RC1 ./configure make makeinstall ln -s /lib/security/pam_mysql.so /lib64/security/
#若是編譯中報錯須要MySQL的庫文件
yum install -y pam-devel mysql mysql-devel cat > /etc/pam.d/open*** << EOF auth sufficient /lib/security/pam_mysql.so user=xxx passwd=xxxxx host=xxxxxx db=*** table=open***user usercolumn=name passwdcolumn=password crypt=2 account required /lib/security/pam_mysql.so user=xxx passwd=xxxxx host=xxxxxx db=*** table=open***user usercolumn=name passwdcolumn=password crypt=2 EOF
五、MySQL配置
mysql -hjconnhrdmgt82.mysql.rds.aliyuncs.com -uzabbix_1 -p -D operations create database ***; #grant all on ***.* to xxx@'%' identified by 'xxxxxx'; create table open***user ( name char(20) NOT NULL, password char(128)default NULL, active int(10) NOT NULL DEFAULT 1, primary key (name) ); insert into open***user (name,password)values('***user',password('***password')); #flush privileges;
六、啓動open***
/etc/init.d/open*** restart 服務端測試testsaslauthd -u ***user -p ***password -s open*** 0:OK "Success."
七、windows客戶端配置
1)客戶端配置文件
cat > someone.o*** << EOF client dev tun proto tcp remote 公網IP 443 resolv-retry infinite nobind persist-key persist-tun ca ca.crt #cert client.crt #key client.key #上面兩個是配置客戶端使用祕鑰登陸的 remote-cert-tls server comp-lzo verb 3 auth-user-pass #此參數後可接文件名例如auth.txtyuanweiyuanwei,文件中記錄帳號和密碼需換行 EOF
2)下載服務端的ca.crt和someone.o***文件到本地
三Iptables配置
*nat :PREROUTING ACCEPT [222:10664] :POSTROUTING ACCEPT [37944:2486906] :OUTPUT ACCEPT [37944:2486906] -A POSTROUTING -s 10.100.0.0/255.255.255.0 -o eth0 -j MASQUERADE COMMIT #以上是iptables的配置文件中須要加入的一條配置能夠配置下面的命令而後保存iptables信息到配置文件中 #iptables -t nat -A POSTROUTING -s10.100.0.0/255.255.255.0 -o eth0 -j MASQUERADE #iptables-save >/etc/sysconfig/iptables 將open***添加到開機啓動項中 chkconfig --add open*** chkconfig open*** on
四總結
Mar 10 17:05:15 jstwpz76bqary8 open***[27972]: PAM unableto dlopen(/lib/security/pam_mysql.so) Mar 10 17:05:15 jstwpz76bqary8 open***[27972]: PAM [error:/lib/security/pam_mysql.so: undefined symbol: pam_set_data]
/var/log/secure中若出現如上錯誤請嘗試使用低版本的open***編譯出來的open***-auth-pam.so動態連接庫文件