手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux下FTP服务器应用之FTPS(FTP+SSL)

[日期:2012-05-08] 来源:Linux社区  作者:xjzhujunjie [字体:大 中 小]

②.配置本地CA证书服务器:

[root@ftp ~]# cd /etc/pki/
[root@ftp pki]# ll
[root@ftp pki]# vim tls/openssl.cnf
45 dir             = /etc/pki/CA

88 countryName             = optional

89 stateOrProvinceName     = optional

90 organizationName        = optional

[root@ftp pki]# cd CA/
[root@ftp CA]# mkdir certs newcerts crl
[root@ftp CA]# touch index.txt serial

[root@ftp CA]# echo "01" >serial

[root@ftp CA]# ll

[root@ftp CA]# openssl genrsa 1024 > private/cakey.pem

Generating RSA private key, 1024 bit long modulus

...........++++++
....++++++

e is 65537 (0x10001)

[root@ftp CA]# chmod 600 private/cakey.pem
[root@ftp CA]# ll private/cakey.pem
-rw------- 1 root root 887 Feb 10 23:22 private/cakey.pem

[root@ftp CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3650

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) [GB]:cn

State or Province Name (full name) [Berkshire]:henan

Locality Name (eg, city) [Newbury]:zhengzhou

Organization Name (eg, company) [My Company Ltd]:junjie

Organizational Unit Name (eg, section) []:soft

Common Name (eg, your name or your server's hostname) []:ca.junjie.com

Email Address []:junjie@junjie.com
[root@ftp CA]#ll

③.为ftp服务器创建证书:

[root@ftp CA]# mkdir /etc/vsftpd/certs
[root@ftp CA]# cd /etc/vsftpd/certs
[root@ftp certs]# openssl genrsa 1024 >vsftpd.key

Generating RSA private key, 1024 bit long modulus

....++++++
...++++++

e is 65537 (0x10001)

[root@ftp certs]# openssl req -new -key vsftpd.key -out vsftpd.csr

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) [GB]:cn

State or Province Name (full name) [Berkshire]:henan

Locality Name (eg, city) [Newbury]:zhengzhou

Organization Name (eg, company) [My Company Ltd]:junjie

Organizational Unit Name (eg, section) []:ftp

Common Name (eg, your name or your server's hostname) []:ftp.junjie.com

Email Address []:ftp@junjie.com
 

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:

An optional company name []:

[root@ftp certs]# openssl ca -in vsftpd.csr -out vsftpd.crt

Using configuration from /etc/pki/tls/openssl.cnf

Check that the request matches the signature

Signature ok

Certificate Details:

        Serial Number: 1 (0x1)
        Validity

            Not Before: Feb 10 15:48:55 2012 GMT

            Not After : Feb 9 15:48:55 2013 GMT
        Subject:
            countryName               = cn
            stateOrProvinceName       = henan
            organizationName          = junjie
            organizationalUnitName    = ftp
            commonName                = ftp.junjie.com
            emailAddress              = junjie@junjie.com
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:FALSE
            Netscape Comment:
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:

                33:C5:01:33:A5:CF:42:9F:24:A9:0D:E9:41:8E:26:C3:1B:7B:18:11

            X509v3 Authority Key Identifier:

                keyid:50:D1:A8:0A:1F:B7:CD:49:94:69:E3:70:E9:AE:93:73:2C:94:66:AC

 

Certificate is to be certified until Feb 9 15:48:55 2013 GMT (365 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
[root@ftp certs]# ll
[root@ftp certs]# chmod 600 *
[root@ftp certs]# ll

④.使ftp服务应用证书:

[root@ftp certs]# cd /etc/vsftpd/            
[root@ftp vsftpd]# vim vsftpd.conf         #增加以下内容

118 rsa_cert_file=/etc/vsftpd/certs/vsftpd.crt

119 rsa_private_key_file=/etc/vsftpd/certs/vsftpd.key

120 force_local_data_ssl=YES
121 force_local_logins_ssl=YES
122 ssl_enable=YES
123 ssl_sslv2=YES
124 ssl_sslv3=YES
125 ssl_tlsv1=YES

[root@ftp vsftpd]# service vsftpd restart

Shutting down vsftpd:                                      [ OK ]
Starting vsftpd for vsftpd:                                [ OK ]
linux
相关资讯       ftp服务器  Linux服务器 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款