open***安裝配置小結

1.         下載並安裝安全

cd /usr/local/src服務器

wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.04.tar.gzide

wget http://open***.net/release/open***-2.1_rc22.tar.gz測試

tar zxvf lzo-2.04.tar.gzui

cd lzo-2.04this

./configure && make && make installspa

tar zxvf open***-2.1_rc22.tar.gz.net

cd open***-2.1_rc22rest

./configure && make && make installcode

whereis open***   查看安裝目錄

 

2.         服務器端設置:

cd /usr/local/src/open***-2.1_rc22/easy-rsa/2.0/

編輯所需的參數(能夠默認)

vi vars

export KEY_COUNTRY="CN"

export KEY_PROVINCE="SH"

export KEY_CITY="Shanghai"

export KEY_ORG="open***"

export KEY_EMAIL="tony@abc.com"

source ./vars

 

下面這個命令在第一次安裝時能夠運行,之後在添加客戶端時千萬別運行,這個命令會清除全部已經生成的

證書密鑰。

./clean-all

生成服務器端ca證書

./build-ca

生成服務器端密鑰證書, 後面這個server-name就是服務器名,能夠自定義。

./build-server-key shidc

一路Enter以後確認Y,證書生成。

生成 diffie hellman 參數

./build-dh

 

生成所需客戶端證書密鑰文件:

./build-key tony

 

3.         Open×××安全增強:

Open×××的配置文件中,tls-auth指令能夠爲SSL/TLS協議的handshake數據包添加HMAC簽名,任何未通過簽名驗正的UDP包都會被丟棄,這就將SSL/TLS的安全提高了一個級別。它能夠爲Open×××UDP提供防止DoS或端口洪泛***、避開對Open×××監聽端口的掃描及防止緩衝區溢出等安全特性。

 

開啓tls-auth功能須要用到一個預共享密鑰,此密鑰常常跟證書等文件一塊兒存放。此預共享密鑰可使用下面的命令生成:

/usr/local/src/open***-2.1_rc22/open*** --genkey --secret ta.key

 

然後在服務器端的配置文件中啓用以下指令:
tls-auth ta.key 0

 

客戶端的配置文件啓用以下指令:
tls-auth ta.key 1

 

4.         建立並編輯服務器端配置文件

mkdir –p /etc/open***/serverkeys

cp /usr/local/src/open***-2.1_rc22/sample-config-files/server.conf /etc/open***/

cd /usr/local/src/open***-2.1_rc22/easy-rsa/2.0/keys/

cp ca.crt dh1024.pem  shidc.crt  shidc.csr  shidc.key  /etc/open***/serverkeys

cp /usr/local/src/open***-2.1_rc22/ta.key /etc/open***/serverkeys

vi /etc/open***/server.conf 修改如下幾項

 

ca /etc/open***/serverkeys/ca.crt

cert /etc/open***/serverkeys/shidc.crt

key  /etc/open***/serverkeys/shidc.key

dh /etc/open***/serverkeys/dh1024.pem

tls-auth /etc/open***/serverkeys/ta.key 0

 

5.         修改完成以後,編輯啓動文件

vi /etc/init.d/open***

 

  
  
           
  
  
  1. open***="" 
  2. open***_locations="/usr/sbin/open*** /usr/local/sbin/open***" 
  3. for location in $open***_locations 
  4. do 
  5.   if [ -f "$location" ] 
  6.   then 
  7.     open***=$location 
  8.   fi 
  9. done 
  10.  
  11. lock="/var/lock/subsys/open***" 
  12.  
  13. piddir="/var/run/open***" 
  14.  
  15. work=/etc/open*** 
  16.  
  17. . /etc/rc.d/init.d/functions 
  18.  
  19. . /etc/sysconfig/network 
  20.  
  21. if [ ${NETWORKING} = "no" ] 
  22. then 
  23.   echo "Networking is down" 
  24.   exit 0 
  25. fi 
  26.  
  27. if ! [ -f  $open*** ]  
  28. then 
  29.   echo "open*** binary not found" 
  30.   exit 0 
  31. fi 
  32.  
  33. case "$1" in 
  34.   start) 
  35.         echo -n $"Starting open***: " 
  36.  
  37.         /sbin/modprobe tun >/dev/null 2>&1 
  38.  
  39.         # From a security perspective, I think it makes 
  40.         # sense to remove this, and have users who need 
  41.         # it explictly enable in their --up scripts or 
  42.         # firewall setups. 
  43.  
  44.         #echo 1 > /proc/sys/net/ipv4/ip_forward 
  45.  
  46.         # Run startup script, if defined 
  47.         if [ -f $work/open***-startup ]; then 
  48.             $work/open***-startup 
  49.         fi 
  50.  
  51.         if [ ! -d  $piddir ]; then 
  52.             mkdir $piddir 
  53.         fi 
  54.  
  55.         if [ -f $lock ]; then 
  56.             # we were not shut down correctly 
  57.             for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do 
  58.               if [ -s $pidf ]; then 
  59.                 kill `cat $pidf` >/dev/null 2>&1 
  60.               fi 
  61.               rm -f $pidf 
  62.             done 
  63.             rm -f $lock 
  64.             sleep 2 
  65.         fi 
  66.  
  67.         rm -f $piddir/*.pid 
  68.         cd $work 
  69.  
  70.         # Start every .conf in $work and run .sh if exists 
  71.         errors=0 
  72.         successes=0 
  73.         for c in `/bin/ls *.conf 2>/dev/null`; do 
  74.             bn=${c%%.conf} 
  75.             if [ -f "$bn.sh" ]; then 
  76.                 . $bn.sh 
  77.             fi 
  78.             rm -f $piddir/$bn.pid 
  79.             $open*** --daemon --writepid $piddir/$bn.pid --config $c --cd $work 
  80.             if [ $? = 0 ]; then 
  81.                 successes=1 
  82.             else 
  83.                 errors=1 
  84.             fi 
  85.         done 
  86.  
  87.         if [ $errors = 1 ]; then 
  88.             failure; echo 
  89.         else 
  90.             success; echo 
  91.         fi 
  92.  
  93.         if [ $successes = 1 ]; then 
  94.             touch $lock 
  95.         fi 
  96.         ;; 
  97.   stop) 
  98.         echo -n $"Shutting down open***: " 
  99.         for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do 
  100.           if [ -s $pidf ]; then 
  101.             kill `cat $pidf` >/dev/null 2>&1 
  102.           fi 
  103.           rm -f $pidf 
  104.         done 
  105.  
  106.         # Run shutdown script, if defined 
  107.         if [ -f $work/open***-shutdown ]; then 
  108.             $work/open***-shutdown 
  109.         fi 
  110.  
  111.         success; echo 
  112.         rm -f $lock 
  113.         ;; 
  114.   restart) 
  115.         $0 stop 
  116.         sleep 2 
  117.         $0 start 
  118.         ;; 
  119.   reload) 
  120.         if [ -f $lock ]; then 
  121.             for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do 
  122.                 if [ -s $pidf ]; then 
  123.                     kill -HUP `cat $pidf` >/dev/null 2>&1 
  124.                 fi 
  125.             done 
  126.         else 
  127.             echo "open***: service not started" 
  128.             exit 1 
  129.         fi 
  130.         ;; 
  131.   reopen) 
  132.         if [ -f $lock ]; then 
  133.             for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do 
  134.                 if [ -s $pidf ]; then 
  135.                     kill -USR1 `cat $pidf` >/dev/null 2>&1 
  136.                 fi 
  137.             done 
  138.         else 
  139.             echo "open***: service not started" 
  140.             exit 1 
  141.         fi 
  142.         ;; 
  143.   condrestart) 
  144.         if [ -f $lock ]; then 
  145.             $0 stop 
  146.             # avoid race 
  147.             sleep 2 
  148.             $0 start 
  149.         fi 
  150.         ;; 
  151.   status) 
  152.         if [ -f $lock ]; then 
  153.             for pidf in `/bin/ls $piddir/*.pid 2>/dev/null`; do 
  154.                 if [ -s $pidf ]; then 
  155.                     kill -USR2 `cat $pidf` >/dev/null 2>&1 
  156.                 fi 
  157.             done 
  158.             echo "Status written to /var/log/messages" 
  159.         else 
  160.             echo "open***: service not started" 
  161.             exit 1 
  162.         fi 
  163.         ;; 
  164.   *) 
  165.         echo "Usage: open*** {start|stop|restart|condrestart|reload|reopen|status}" 
  166.         exit 1 
  167.         ;; 
  168. esac 
  169. exit 0 

 

6.         啓動open***

/etc/init.d/open*** start

查看服務狀況

Netstat –tunlp查看默認的1194端口是否開啓

開啓路由轉發

sysctl -w net.ipv4.ip_forward=1

調整iptables策略,若是open*** server非網關,如需訪問內網服務器須要添加iptables SNAT

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -d 172.16.0.0/24 -j SNAT --to-source 172.16.0.10

#172.16.0.10爲open*** server的內網口IP

 

7.         window上安裝open***-2.1_rc15-install.exe

複製ca.crt  tony.crt  tony.key  ta.keyopen***安裝目錄---config目錄

config裏面編輯Open***客戶端配置文件

 

  
  
           
  
  
  1. client 
  2. dev tun
  3. proto udp 
  4. comp-lzo #對數據進行壓縮,注意Server和Client保持一致
  5. #auth-user-pass   啓用pam-auth時使用
  6. remote 192.168.255.193     1194 
  7. resolv-retry infinite 
  8. nobind 
  9. persist-key 
  10. persist-tun 
  11. ca   ca.crt 
  12. cert  tony.crt 
  13. key  tony.key 
  14. ns-cert-type server 
  15. tls-auth  ta.key 1 
  16. verb 3 
  17. #log  c:\tun11-***.log 

 

就能夠在客戶端進行撥號測試了

 

8.         啓用auth-pam模塊進行雙因素認證

yum –y install pam-devel

 

生成open***-auth-pam.so

cd /usr/local/src/open***-2.1_rc22/plugin/auth-pam/

make

 

mkdir /usr/lib/open***/

cp open***-auth-pam.so /usr/lib/open***/

 

vi /etc/open***/server.conf 在最後添加

plugin /usr/lib/open***/open***-auth-pam.so system-auth

 

從新加載

/etc/init.d/open*** reload

 

客戶端配置文件啓用auth-user-pass

就能夠用open***服務器系統用戶名密碼來進行驗證,同時再用證書驗證。

相關文章
相關標籤/搜索