centos6.6安装Open×××
一、实验环境
Open××× server配置两张网卡hostonly配置10.1.1.1,vmnet1配置172.16.1.1
内网服务器配置一张网卡采用hostonly配置10.1.1.2
Open××× client配置一张网卡采用vmnet1配置172.16.1.2
二、安装依赖包
1.安装epel源
2.安装openssl、openssl-devel、lzo-devel
# yum install openssl openssl-devel lzo-devel
三、安装open***
1.下载软件包open***-2.0.9.tar.gz
2.编译安装
# tar xf open***-2.0.9.tar.gz # cd open***-2.0.9 # ./configure --prefix=/usr/local/open*** # make # make install
3.创建相关目录
# cd /usr/local/open*** # mkdir {etc,var} # mkdir etc/keys # mkdir var/run
4.easy-rsa配置
# cp -rp /usr/local/src/open***-2.0.9/easy-rsa /usr/local/open***/etc/
5.创建CA证书和密钥
# cd /usr/local/open***/etc/easy-rsa/2.0 # 设置变量 # vi vars export KEY_COUNTRY="CN" export KEY_PROVINCE="FJ" export KEY_CITY="FZ" export KEY_ORG="Opr" export KEY_EMAIL="[email protected]" # source ./vars # 初始化证书的授权中心 # ./clean-all # 清除keys目录下面的文件 # ./build-ca # 创建ca证书 Generating a 1024 bit RSA private key ................................++++++ .....++++++ writing new private key to 'ca.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [CN]: State or Province Name (full name) [FJ]: Locality Name (eg, city) [FZ]: Organization Name (eg, company) [Opr]: Organizational Unit Name (eg, section) []:HB Common Name (eg, your name or your server's hostname) [Opr CA]:CA Email Address [[email protected]]:
6.创建服务端证书和密钥
[root@localhost 2.0]# ./build-key-server server Generating a 1024 bit RSA private key ..............................++++++ .....................................++++++ writing new private key to 'server.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [CN]: State or Province Name (full name) [FJ]: Locality Name (eg, city) [FZ]: Organization Name (eg, company) [Opr]: Organizational Unit Name (eg, section) []:HB Common Name (eg, your name or your server's hostname) [server]: Email Address [[email protected]]: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /usr/local/open***/etc/easy-rsa/2.0/openssl.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'CN' stateOrProvinceName :PRINTABLE:'FJ' localityName :PRINTABLE:'FZ' organizationName :PRINTABLE:'Opr' organizationalUnitName:PRINTABLE:'HB' commonName :PRINTABLE:'server' emailAddress :IA5STRING:'[email protected]' Certificate is to be certified until Aug 27 02:13:13 2027 GMT (3650 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated
7.创建客户端证书和密钥
[root@localhost 2.0]# ./build-key henairong Generating a 1024 bit RSA private key ..........++++++ ..................................++++++ writing new private key to 'henairong.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [CN]: State or Province Name (full name) [FJ]: Locality Name (eg, city) [FZ]: Organization Name (eg, company) [Opr]: Organizational Unit Name (eg, section) []:HB Common Name (eg, your name or your server's hostname) [henairong]: Email Address [[email protected]]:[email protected] Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /usr/local/open***/etc/easy-rsa/2.0/openssl.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'CN' stateOrProvinceName :PRINTABLE:'FJ' localityName :PRINTABLE:'FZ' organizationName :PRINTABLE:'Opr' organizationalUnitName:PRINTABLE:'HB' commonName :PRINTABLE:'henairong' emailAddress :IA5STRING:'[email protected]' Certificate is to be certified until Aug 27 02:15:28 2027 GMT (3650 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated
8.创建迪菲霍尔曼密钥交换参数
# ./build-dh
9.复制服务端证书及相关密钥文件
# cd /usr/local/open***/etc/easy-rsa/2.0/keys/ # cp ca.crt dh1024.pem server.crt server.key /usr/local/open***/etc/keys/
四、配置Open***
1.提供服务端配置文件
# cp /usr/local/src/open***-2.0.9/sample-config-files/server.conf /usr/local/open***/etc/
2.修改配置文件
# cd /usr/local/open***/etc/ # vi server.conf local 172.16.1.1 port 1194 proto tcp dev tun ca /usr/local/open***/etc/keys/ca.crt cert /usr/local/open***/etc/keys/server.crt key /usr/local/open***/etc/keys/server.key # This file should be kept secret dh /usr/local/open***/etc/keys/dh1024.pem server 192.168.100.0 255.255.255.0 #给客户端分配地址池,注意:不能和×××服务器内网网段有相同 ifconfig-pool-persist ipp.txt push "route 10.1.1.0 255.255.255.0" #允许客户端访问内网的网段 client-to-client keepalive 10 120 comp-lzo max-clients 100 user nobody group nobody persist-key persist-tun status /usr/local/open***/var/open***-status.log log /usr/local/open***/var/open***.log verb 3 auth-user-pass-verify /usr/local/open***/etc/checkpsw.sh via-env username-as-common-name
3.提供用户密码账号验证配置
# vi checkpsw.sh #!/bin/sh ########################################################### # checkpsw.sh (C) 2004 Mathias Sundman# # 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 # chmod +x checkpsw.sh 提供账号密码文件 # vi psw-file # chmod 400 psw-file
4.配置服务脚本
修改文件权限 # chown -R nobody.nobody /usr/local/open*** 提供服务脚本 # cp -p /usr/local/src/open***-2.0.9/sample-scripts/open***.init /etc/init.d/open*** 修改服务脚本 # vi /etc/init.d/open*** open***="/usr/local/open***/sbin/open***" # PID directory piddir="/usr/local/open***/var/run/open***" # Our working directory work=/usr/local/open***/etc
5.启动服务
# service open*** start
五、安装配置windows客户端
1.下载软件包
open***-install-2.3.11-I601-x86_64.exe
2.双机安装
3.提供配置文件、密钥及证书文件
从服务端下载刚才生产的客户端证书及密钥,CA证书
下载源码目录下客户端配置文件
/usr/local/src/open***-2.0.9/sample-config-files/client.conf
将以上文件复制到安装目录下
C:\Program Files\Open×××\config
4.修改配置文件client.conf
client dev tun proto tcp remote 172.16.1.1 1194 resolv-retry infinite nobind persist-key persist-tun ca ca.crt cert henairong.crt key henairong.key comp-lzo verb 3 auth-user-pass passwd
5.创建账号密码文件
C:\Program Files\Open×××\config\passwd
henairong
nihao123!
6.启动服务
以管理员身份运行
验证
在10.1.1.2远程主机上需要添加路由
# route add -net 192.168.100.0/24 gw 10.1.1.1
六、客户端证书吊销
# cd /usr/local/open***/etc/easy-rsa/2.0 # source ./vars # ./revoke-full henairong
出现以上错误,解决如下
修改openssl.conf注释如下几行
#[ pkcs11_section ] #engine_id = pkcs11 #dynamic_path = /usr/lib/engines/engine_pkcs11.so #MODULE_PATH = $ENV::PKCS11_MODULE_PATH #PIN = $ENV::PKCS11_PIN #init = 0 [root@localhost 2.0]# ./revoke-full henairong Using configuration from /usr/local/open***/etc/easy-rsa/2.0/openssl.cnf Revoking Certificate 02. Data Base Updated Using configuration from /usr/local/open***/etc/easy-rsa/2.0/openssl.cnf henairong.crt: C = CN, ST = FJ, L = FZ, O = Opr, OU = HB, CN = henairong, emailAddress = [email protected] error 8 at 0 depth lookup:CRL signature failure 140167567640392:error:0D0C50A1:asn1 encoding routines:ASN1_item_verify:unknown message digest algorithm:a_verify.c:217:
这条命令执行完成之后, 会在 keys 目录下面, 生成一个 crl.pem 文件,这个文件中包含了吊销证书的名单。
成功注销某个证书之后,可以打开 keys/index.txt 文件,可以看到被注销的证书前面,已标记为R.
修改服务端配置文件打开crl-verify 选项
# vi /usr/local/open***/etc/server.conf crl-verify /usr/local/open***/etc/easy-rsa/2.0/keys/crl.pem
重启服务
# service open*** restart