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***服务器系统用户名密码来进行验证,同时再用证书验证。

相关文章
相关标签/搜索