天天看點

基于ssl的ftp安全檔案傳輸------------ftps

一、簡介

        ftp檔案傳輸是一種明文的傳輸方式,通過抓包工具可以輕易的截取使用者的傳輸内容以及密

    碼等資訊,是以需要一種更安全的傳輸機制。

        ftp的安全傳輸方式有多種,例如:ftps和sftp。但是最經常用的應該是基于ssl的FTPS,

    它通過ssl安全機制對ftp的傳輸内容進行加密。

FTPS是在安全套接層使用标準的FTP協定和指令的一種增強型TFP協定,為FTP協定和

資料通道增加了SSL安全功能。FTPS也稱作“FTP-SSL”和“FTP-over-SSL”。SSL是一個在客戶

機和具有SSL功能的伺服器之間的安全連接配接中對資料進行加密和解密的協定。

二、SFTP和FTPS之間的差別

都是為ftp連接配接加密,協定非常相似。一個是借助ssl協定加密,一個時借助ssh加密。

Ssl 是為http/smtp等加密設計的,ssh是為telnet/ftp等加密、建立傳輸通道而設計的。

三、FTPS的實作

(1)實驗所需安裝的包

         Redhat linux 5.4

          mod_ssl-2.2.3-31.el5.i386.rpm   #ssl

          vsftpd-2.0.5-16.el5.i386.rpm     #ftp

          wireshark-1.0.8-1.el5_3.1.i386.rpm  #抓包工具(測試使用)

(2)FTPS環境搭建過程

     [root@localhost ~]# mount /dev/cdrom /mnt/cdrom/

     [root@localhost ~]# cd /mnt/cdrom/Server/

     [root@localhost Server]# yum install -y  mod_ssl-2.2.3-31.el5.i386.rpm

     [root@localhost Server]# yum install -y  vsftpd-2.0.5-16.el5.i386.rpm 

     [root@localhost Server]# yum install -y wireshark

      下面進行CA的建立:

       [root@localhost Server]# cd /etc/pki/

       [root@localhost pki]# ll

基于ssl的ftp安全檔案傳輸------------ftps

      [root@localhost pki]# vim tls/openssl.cnf

基于ssl的ftp安全檔案傳輸------------ftps
基于ssl的ftp安全檔案傳輸------------ftps

說明:可以通過 :88,90 s/match/optional  指令進行快速修改

[root@localhost pki]# cd CA/

[root@localhost CA]# mkdir crl certs newcerts  #建立所對應的目錄

[root@localhost CA]# touch index.txt serial   #建立所需要的檔案

[root@localhost CA]# ll

基于ssl的ftp安全檔案傳輸------------ftps

   [root@localhost CA]# echo "01" >serial    #将序号01追加到serial中

   [root@localhost CA]# cat serial 

   [root@localhost CA]# openssl genrsa 1024 >private/cakey.pem  #建立ca的私鑰

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

   #建立ca的證書

基于ssl的ftp安全檔案傳輸------------ftps

   [root@localhost CA]# chmod 600 private/cakey.pem #修改權限,安全考慮

   [root@localhost CA]# cd /etc/vsftpd/

   [root@localhost vsftpd]# mkdir certs

   [root@localhost vsftpd]# cd certs/

   [root@localhost certs]# openssl genrsa 1024 >vsftpd.key   #産生FTP的私鑰

   [root@localhost certs]# openssl req -new -key vsftpd.key -out vsftpd.csr #産生FTP的證書請求檔案

基于ssl的ftp安全檔案傳輸------------ftps

  [root@localhost certs]# openssl ca -in vsftpd.csr -out vsftpd.cert  #CA頒發證書給FTP

基于ssl的ftp安全檔案傳輸------------ftps

[root@localhost certs]# chmod 600 *

[root@localhost certs]# vim /etc/vsftpd/vsftpd.conf  #編輯ftp的配置檔案

基于ssl的ftp安全檔案傳輸------------ftps

[root@localhost certs]# service  vsftpd restart

至此FTPS的環境已經搭建完畢,下面我們就來進行抓包測試,看是否能看到使用者的資訊:

ftp的連接配接本人使用的是flashfxp用戶端

基于ssl的ftp安全檔案傳輸------------ftps

我們先在ftp伺服器上進行抓包,在進行ftp的連接配接,觀察所抓到的包的情況;

[root@localhost ~]# tshark -ni eth0 -R "tcp.dstport eq 21"  #在eth0上的21端口進行抓包

基于ssl的ftp安全檔案傳輸------------ftps

在不用ftps時:

基于ssl的ftp安全檔案傳輸------------ftps
基于ssl的ftp安全檔案傳輸------------ftps

使用ftps後:

基于ssl的ftp安全檔案傳輸------------ftps
基于ssl的ftp安全檔案傳輸------------ftps

說明:已經加密,是以看不到了,這樣顯得更安全。

繼續閱讀