|
板凳
楼主 |
发表于 2021-10-1 15:22:05
|
只看该作者
4、生成服务端的密钥文件
使用当前目录的 build-key-server 命令创建
[root@VPN-A 2.0]# ./build-key-server server <--后面的是 server 是指定的文件名
注意:这个名字定义好后,以后都会需要调用到的。
[root@VPN-A 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) [GD]: <--默认按“回车”即可
Locality Name (eg, city) [ShenZhen]: <--默认按“回车”即可
Organization Name (eg, company) [SYS]: <--默认按“回车”即可
Organizational Unit Name (eg, section) [tear]: <--默认按“回车”即可
Common Name (eg, your name or your server's hostname) [server]: <--默认按“回车”即可
Name [tear]: <--默认按“回车”即可
Email Address [tear@sys.local]: <--默认按“回车”即可
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456 <--要给一个密码,这个密码是在你发起证书请求的密码,这里
设置为:123456,根据自己的要求更改。
An optional company name []:sys <--一个可选的公司名
Using configuration from /home/tear/tools/openvpn/openvpn-2.2.2/easy-rsa/2.0/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName RINTABLE:'CN'
stateOrProvinceName RINTABLE:'GD'
localityName RINTABLE:'ShenZhen'
organizationName RINTABLE:'SYS'
organizationalUnitNameRINTABLE:'tear'
commonName RINTABLE:'server'
name RINTABLE:'tear'
emailAddress :IA5STRING:'tear@sys.local'
Certificate is to be certified until Aug 12 07:17:54 2026 GMT (3650 days)
Sign the certificate? [y/n]:y <--输入 y
1 out of 1 certificate requests certified, commit? [y/n]y <--输入 y
Write out database with 1 new entries
Data Base Updated <--有这个提示为成功
查看所生成的证书文件:
[root@VPN-A 2.0]# ls keys/
01.pem ca.key index.txt.attr serial server.crt server.key
ca.crt index.txt index.txt.old serial.old server.csr
5、生成客户端证书和 key 文件
注意:客户端证书可以给不同的用户生成不同的证书和密钥文件,那样以后方便管理。
使用当前目录下的 build-key 命令
[root@VPN-A 2.0]# ./build-key tear <--在工作当中,这个其实就是使用者的名字
Generating a 1024 bit RSA private key
.....++++++
.................................++++++
writing new private key to 'tear.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) [GD]: <--默认按“回车”即可
Locality Name (eg, city) [ShenZhen]: <--默认按“回车”即可
Organization Name (eg, company) [SYS]: <--默认按“回车”即可
Organizational Unit Name (eg, section) [tear]: <--默认按“回车”即可
Common Name (eg, your name or your server's hostname) [tear]: <--默认按“回车”即可
Name [tear]: <--默认按“回车”即可
Email Address [tear@sys.local]: <--默认按“回车”即可
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456 <--要给一个密码,这个密码是在你发起证书请求的密码,这里
设置为:123456,根据自己的要求更改。
An optional company name []:tear <--默认按“回车”即可
Using configuration from /home/tear/tools/openvpn/openvpn-2.2.2/easy-rsa/2.0/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName RINTABLE:'CN'
stateOrProvinceName RINTABLE:'GD'
localityName RINTABLE:'ShenZhen'
organizationName :PRINTABLE:'SYS'
organizationalUnitName:PRINTABLE:'tear'
commonName :PRINTABLE:'tear'
name :PRINTABLE:'tear'
emailAddress :IA5STRING:'tear@sys.local'
Certificate is to be certified until Aug 12 07:26:44 2026 GMT (3650 days)
Sign the certificate? [y/n]:y <--输入 y
1 out of 1 certificate requests certified, commit? [y/n]y <--输入 y
Write out database with 1 new entries
Data Base Updated
[root@VPN-A 2.0]# ls keys/
01.pem ca.crt index.txt index.txt.attr.old serial server.crt server.key tear.csr
02.pem ca.key index.txt.attr index.txt.old serial.old server.csr tear.crt tear.key
生成了 tear 用户的三个文件。
此时,就一共有两个证书及密钥分别是:公用的 CA 证书、服务端的证书、客户端的证书。
需要注意的是:如果使用 build-key 来创建用户的证书,那么这个用户只需要提供证书就可进行拨号连接,不需要密码。
下面创建一个需要使用证书和密码认证的用户证书及密钥文件。
使用当前目录下的 build-key-pass 命令:
[root@VPN-A 2.0]# ./build-key-pass tom
Generating a 1024 bit RSA private key
.........................................++++++
....++++++
writing new private key to 'tom.key'
Enter PEM pass phrase: <--输入用户密码,当拨号时就会需要密码
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.
-----
Country Name (2 letter code) [CN]: <--默认按“回车”即可
State or Province Name (full name) [GD]: <--默认按“回车”即可
Locality Name (eg, city) [ShenZhen]: <--默认按“回车”即可
Organization Name (eg, company) [SYS]: <--默认按“回车”即可
Organizational Unit Name (eg, section) [tear]: <--默认按“回车”即可
Common Name (eg, your name or your server's hostname) [tom]: <--默认按“回车”即可
Name [tear]: <--默认按“回车”即可
Email Address [tear@sys.local]: <--默认按“回车”即可
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456 <--要给一个密码,这个密码是在你发起证书请求的密码,这里
设置为:123456,根据自己的要求更改。
An optional company name []:sys <--默认按“回车”即可
Using configuration from /home/tear/tools/openvpn/openvpn-2.2.2/easy-rsa/2.0/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName :PRINTABLE:'CN'
stateOrProvinceName :PRINTABLE:'GD'
localityName :PRINTABLE:'ShenZhen'
organizationName :PRINTABLE:'SYS'
organizationalUnitName:PRINTABLE:'tear'
commonName :PRINTABLE:'tom'
name :PRINTABLE:'tear'
emailAddress :IA5STRING:'tear@sys.local'
Certificate is to be certified until Aug 12 07:46:15 2026 GMT (3650 days)
Sign the certificate? [y/n]:y <--输入 y
1 out of 1 certificate requests certified, commit? [y/n]y <--输入 y
Write out database with 1 new entries
Data Base Updated
[root@VPN-A 2.0]# ls keys/
01.pem ca.crt index.txt.attr serial server.csr tear.csr tom.csr
02.pem ca.key index.txt.attr.old serial.old server.key tear.key tom.key
03.pem index.txt index.txt.old server.crt tear.crt tom.crt
|
+10
|