1. 程式人生 > 實用技巧 >基於ssl的ftp詳細配置過程

基於ssl的ftp詳細配置過程

ftps:基於sslftp

ssl_enable=YES //啟用vsftpdssl的支援的功能

all_anon_ssl=NO //是否啟用匿名使用者使用ssl,一般都是否定

force_local_data_ssl=YES //是否強制本地使用者資料傳輸必須基於ssl

force_local_logins_ssl=YES //是否強制本地使用者登入的時候,帳號密碼也基於ssl

ssl_tlsv1=YES //是否支援tlsv1

ssl_tlsv2=NO //是否支援tlsv2 預設情況下v2v3都是不支援的

ssl_tlsv3=YES //是否支援ltsv3

rsa_cert_file=/etc/vsftpd/vsftpd.cert

//要想建立ssl會話,必須要有證書,給vsftpd建立一個證書

rsa_private_key_file=/etc/vsftpd/ssl/vsftp.key

建立證書:

  1. [[email protected]~]#cd/etc/pki/CA/
  2. [[email protected]CA]#(umask077;opensslgenrsa1024>private/cakey.pem)
  3. 在建立自簽證書前首先要修改配置檔案
  4. [[email protected]CA]#vim../tls/openssl.cnf
  5. 修改dir=../../CA為dir=/etc/pki/CA

儲存退出

  1. [[email protected]
    CA]#opensslreq-
    new-x509-days3650-keyprivate/cakey.pem-outcacert.pem//頒發請求
  2. Youareabouttobeaskedtoenterinformationthatwillbeincorporated
  3. intoyourcertificaterequest.
  4. WhatyouareabouttoenteriswhatiscalledaDistinguishedNameoraDN.
  5. Therearequiteafewfieldsbutyoucanleavesomeblank
  6. Forsomefieldstherewillbeadefaultvalue,
  7. Ifyouenter'.'
    ,thefieldwillbeleftblank.
  8. -----
  9. CountryName(2lettercode)[GB]:CN
  10. StateorProvinceName(fullname)[Berkshire]:HA
  11. LocalityName(eg,city)[Newbury]:ZZ
  12. OrganizationName(eg,company)[MyCompanyLtd]:YANG
  13. OrganizationalUnitName(eg,section)[]:Tech
  14. CommonName(eg,yournameoryourserver'shostname)[]:ca.yang.com
  15. EmailAddress[]:[email protected]

建立目錄:

  1. [[email protected]CA]#mkdircrlcertsnewcerts

建立檔案

  1. [[email protected]CA]#touchindex.txt
  2. [[email protected]CA]#echo01>serial

下面開始為fstpd建立私鑰,建立證書,頒發請求,再由CA簽署就可以了

  1. [[email protected]CA]#cd/etc/vsftpd
  2. [[email protected]vsftpd]#mkdirssl
  3. [[email protected]vsftpd]#cdssl
  4. [[email protected]ssl]#(umask077;opensslgenrsa1024>vsftpd.key)
  5. [[email protected]ssl]#opensslreq-new-keyvsftpd.key-outvsftpd.csr-days3650
  6. Youareabouttobeaskedtoenterinformationthatwillbeincorporated
  7. intoyourcertificaterequest.
  8. WhatyouareabouttoenteriswhatiscalledaDistinguishedNameoraDN.
  9. Therearequiteafewfieldsbutyoucanleavesomeblank
  10. Forsomefieldstherewillbeadefaultvalue,
  11. Ifyouenter'.',thefieldwillbeleftblank.
  12. -----
  13. CountryName(2lettercode)[GB]:CN
  14. StateorProvinceName(fullname)[Berkshire]:HA
  15. LocalityName(eg,city)[Newbury]:ZZ
  16. OrganizationName(eg,company)[MyCompanyLtd]:YANG
  17. OrganizationalUnitName(eg,section)[]:Tech
  18. CommonName(eg,yournameoryourserver'shostname)[]:ftp.yang.com//此處一定要和你的主機名一致
  19. EmailAddress[]:[email protected]
  20. Pleaseenterthefollowing'extra'attributes
  21. tobesentwithyourcertificaterequest
  22. Achallengepassword[]:
  23. Anoptionalcompanyname[]:

簽署證書

  1. [[email protected]ssl]#opensslca-invsftpd.csr-outvsftpd.crt

一直yesOK

  1. [[email protected]ssl]#ll
  2. total24
  3. -rw-r--r--1rootroot3180Oct921:49vsftpd.crt
  4. -rw-r--r--1rootroot680Oct921:44vsftpd.csr
  5. -rw-------1rootroot891Oct921:39vsftpd.key

證書製作完畢

定義證書的配置檔案

  1. [[email protected]vsftpd]#vimvsftpd.conf
  2. 新增一下內容
  3. #ForSSL
  4. ssl_enable=YES
  5. force_local_data_ssl=YES
  6. force_local_logins_ssl=YES
  7. ssl_tlsv1=YES
  8. ssl_sslv3=YES
  9. ssl_sslv2=NO
  10. rsa_cert_file=/etc/vsftpd/ssl/vsftpd.crt
  11. rsa_private_key_file=/etc/vsftpd/ssl/vsftpd.key

儲存退出

重啟服務,檢視埠,觀察是否正常

  1. [[email protected]vsftpd]#servicevsftpdrestart
  2. Shuttingdownvsftpd:[OK]
  3. Startingvsftpdforvsftpd:[OK]
  4. [[email protected]vsftpd]#netstat-tnlp|grep21
  5. tcp000.0.0.0:210.0.0.0:*LISTEN10671/vsftpd

效果如下所示,傳輸的報文已經加密成密文

轉載於:https://blog.51cto.com/inspriion/1050017