Note: using Easy-RSA configuration from: /etc/easy-rsa/easyrsa3/vars Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
Enter New CA Key Passphrase: #输入CA密码,记录下 Re-Enter New CA Key Passphrase: #确认密码 Generating RSA privatekey, 2048 bit long modulus ..................+++ ............................................+++ eis65537 (0x10001) 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 Forsome fields there will be a default value, If you enter '.', the field will be left blank. ----- Common Name (eg: your user, host, or server name) [Easy-RSA CA]:server # ca证书名称
CA creation complete and you may now import andsign cert requests. Your new CA certificate file for publishing is at: /etc/easy-rsa/easyrsa3/pki/ca.crt
[root@VM-0-13-centos easyrsa3]# ./easyrsa gen-req server nopass
Note: using Easy-RSA configuration from: /etc/easy-rsa/easyrsa3/vars Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017 Generating a 2048 bit RSA private key ....................+++ ........................+++ writing newprivate key to '/etc/easy-rsa/easyrsa3/pki/easy-rsa-32328.KOVmFR/tmp.kdL0Yx' ----- 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. ----- Common Name (eg: your user, host, or server name) [server]:vpc-server #输入服务端名称
Keypair and certificate request completed. Your files are: req: /etc/easy-rsa/easyrsa3/pki/reqs/server.req key: /etc/easy-rsa/easyrsa3/pki/private/server.key
[root@VM-0-13-centos easyrsa3]# ./easyrsa sign server server
Note: using Easy-RSA configuration from: /etc/easy-rsa/easyrsa3/vars Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
You are aboutto sign the following certificate. Please check overthe details shown belowfor accuracy. Note that this request has not been cryptographically verified. Please be sure it came from a trusted source orthat you have verified the request checksum withthe sender.
Request subject, to be signed as a server certificate for825 days:
subject= commonName = vpc-server
Type theword 'yes' tocontinue, or any other input to abort. Confirm request details: yes #输入yes Using configuration from /etc/easy-rsa/easyrsa3/pki/easy-rsa-345.HZwt53/tmp.7IIgHU Enter pass phrase for /etc/easy-rsa/easyrsa3/pki/private/ca.key: #输入之前配置的CA密码 Check thatthe request matches the signature Signature ok The Subject's Distinguished Name isas follows commonName :ASN.112:'vpc-server' Certificate isto be certified until Jun 2909:02:242023 GMT (825 days)
Write out database with1 new entries Data Base Updated
Certificate created at: /etc/easy-rsa/easyrsa3/pki/issued/server.crt
创建数据穿越密钥
1 2 3 4 5 6 7 8 9
[root@VM-0-13-centos easyrsa3]# ./easyrsa gen-dh
Note: using Easy-RSA configuration from: /etc/easy-rsa/easyrsa3/vars Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017 Generating DH parameters, 2048 bit long safe prime, generator 2 This is going to take a long time ....................+..............................................................................................................................................................................................+..........................................................................................................................+..........................................+...................+...............................
DH parameters of size2048 created at /etc/easy-rsa/easyrsa3/pki/dh.pem
创建client证书
初始化目录
1 2 3 4 5 6 7 8 9 10 11 12
[root@VM-0-13-centos easyrsa3]# cd /etc/client/ [root@VM-0-13-centos client]# cp -R /root/easy-rsa/easyrsa3/ . [root@VM-0-13-centos client]# ll drwxr-xr-x 3 root root 4096 Mar 2617:07 easyrsa3 [root@VM-0-13-centos client]# cd easyrsa3/ [root@VM-0-13-centos easyrsa3]# ./easyrsa init-pki
init-pki complete; you may now create a CA or requests. Your newly created PKI dir is: /etc/client/easyrsa3/pki
[root@VM-0-13-centos easyrsa3]# ls easyrsa openssl-easyrsa.cnf pki vars.example x509-types
[root@VM-0-13-centos easyrsa3]# ./easyrsa build-ca Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
Enter New CA Key Passphrase: #输入ca密码 Re-Enter New CA Key Passphrase: #确认CA密码 Generating RSA private key, 2048 bit long modulus .....................................+++ ...........................................+++ eis65537 (0x10001) You are about tobe 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 ora DN. There are quite a few fields but you can leave some blank For some fields there will bea default value, If you enter '.', the field will beleft blank. ----- Common Name (eg: your user, host, or server name) [Easy-RSA CA]:client-ca #输入ca证书名称
CA creation completeand you may now import andsign cert requests. Your new CA certificate filefor publishing is at: /etc/client/easyrsa3/pki/ca.crt
[root@VM-0-13-centos easyrsa3]# ./easyrsa gen-req client Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017 Generating a 2048 bit RSA privatekey ........................................................+++ .............................................+++ writing newprivatekeyto'/etc/client/easyrsa3/pki/easy-rsa-1789.jZxBCq/tmp.1l4buX' Enter PEM pass phrase: #输入客户端CA密码,也是将来登录VPN客户密码! Verifying - Enter PEM pass phrase: ----- 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. ----- Common Name (eg: your user, host, or server name) [client]:niewx #起名字
Keypair and certificate request completed. Your files are: req: /etc/client/easyrsa3/pki/reqs/client.req key: /etc/client/easyrsa3/pki/private/client.key
导入客户端证书
1 2 3 4 5 6 7 8
[root@VM-0-13-centos easyrsa3]# cd /etc/easy-rsa/easyrsa3 [root@VM-0-13-centos easyrsa3]# ./easyrsa import-req /etc/client/easyrsa3/pki/reqs/client.req client
Note: using Easy-RSA configurationfrom: /etc/easy-rsa/easyrsa3/vars Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
The request has been successfully imported with a short nameof: client You may now use this nametoperform signing operations on this request.
[root@VM-0-13-centos easyrsa3]# cd /etc/easy-rsa/easyrsa3 [root@VM-0-13-centos easyrsa3]# ./easyrsa sign client client Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
You are aboutto sign the following certificate. Please check overthe details shown belowfor accuracy. Note that this request has not been cryptographically verified. Please be sure it came from a trusted source orthat you have verified the request checksum withthe sender.
Request subject, to be signed as a client certificate for825 days:
subject= commonName = niewx
Type theword 'yes' tocontinue, or any other input to abort. Confirm request details: yes # 输入yes Using configuration from /etc/client/easyrsa3/pki/easy-rsa-2777.2aZHdK/tmp.9RSG1Q Enter pass phrase for /etc/client/easyrsa3/pki/private/ca.key: #客户端ca密码 Check thatthe request matches the signature Signature ok The Subject's Distinguished Name isas follows commonName :ASN.112:'niewx' Certificate isto be certified until Jun 2909:16:552023 GMT (825 days)
Write out database with1 new entries Data Base Updated
Certificate created at: /etc/easy-rsa/easyrsa3/pki/issued/client.crt
[root@VM-0-13-centos openvpn]# cd /etc/openvpn [root@VM-0-13-centos openvpn]# vim server.conf
local 0.0.0.0 port 55555 proto tcp dev tun ca /etc/server/ca.crt cert /etc/server/server.crt key /etc/server/server.key # Thisfile should be kept secret dh /etc/server/dh.pem server 192.168.1.0255.255.255.0 ifconfig-pool-persist ipp.txt keepalive 10120 persist-key persist-tun status openvpn-status.log verb 3 comp-lzo push"route 10.0.0.0 255.0.0.0" client-to-client log /var/log/openvpn.log