FTPS(上)

FTPS

    FTPS也稱作“FTP-SSL”和“FTP-over-SSL” ,它是一種更安全的FTP傳輸服務

一種多傳輸協議,相當於加密版的FTP。

    FTPS優勢

    FTP傳輸並不是很安全,在FTP上所有的交流都是簡單的文本,可以很容易的獲取到,當你在FTP服務器上收發文件的時候,你面臨兩個風險。第一個風險是在上載文件的時候爲文件加密。第二個風險是,這些文件在你等待接收方下載的時候將停留在FTP服務器上,這時你如何保證這些文件的安全。你的第二個選擇(創建一個支持SSL的FTP服務器)能夠讓你的主機使用一個FTPS連接上載這些文件。這包括使用一個在FTP協議下面的SSL層加密控制和數據通道。一種替代FTPS的協議是安全文件傳輸協議(SFTP)。這個協議使用SSH文件傳輸協議加密從客戶機到服務器的FTP連接。  

    FTPS是在安全套接層使用標準的FTP協議和指令的一種增強型TFP協議,爲FTP協議和數據通道增加了SSL安全功能。SSL是一個在客戶機和具有SSL功能的服務器之間的安全連接中對數據進行加密和解密的協議。  和sftp連接方法類似,在windows中可以使用FileZilla等傳輸軟件來連接FTPS進行上傳,下載文件,建立,刪除目錄等操作,在FileZilla連接時,有顯式和隱式TLS/SSL連接之分,連接時也有指紋提示。

儘管這個並不是特別的危險,但是我們可以稍微的修改下使之更加安全。

 配置Vsftpd服務

 測試環境

FTP: Vsftpd

由於FTP的用戶分爲以下三類實體用戶,訪客,匿名登錄者,下面就從主要的實用

戶和匿名用戶來分別說明。

實體用戶設置

LDAP用戶設置:

由於系統已經配置完成openldap,這裏就可以讓LDAP裏面的用戶能夠使用FTP.

cd /etc/pam.d/

mv vsftpd{,.bak}

cp /etc/pam.d/system-auth /etc/pam.d/vsftpd

 編輯配置文件:

vim /etc/vsftpd/vsftpd.conf

#Anonymous users

anonymous_enable=NO

#Local users

local_enable=YES

write_enable=YES

local_umask=022

local_root=/home/pub/ #共享目錄

userlist_enable=YES

userlist_deny=YES

userlist_file=/etc/vsftpd/user_list

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list #實現chroot功能的用戶名單

#Host

dirmessage_enable=YES

xferlog_enable=YES

connect_from_port_20=YES

xferlog_std_format=YES

pam_service_name=vsftpd

listen=YES

tcp_wrappers=YES

use_localtime=YES

banner_file=/etc/vsftpd/welcome.txt #登錄FTP後的歡迎信息

local_max_rate=100000

max_clients=10

#max_per_ip=1

創建文件

touch /etc/vsftpd/chroot_list

mkdir /home/pub

chmod o+w /home/pub

touch /etc/vsftpd/welcome.txt

echo "Welcome" >>welcome.txt

啓動FTP

/etc/init.d/vsftpd start

ftp localhost

Connected to test.com.

220-Welcome to my FTP Server

220

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (localhost:root): jack #使用系統裏面的帳號和密碼

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp>

ftp localhost

Connected to test.com.

220-Welcome to my FTP Server

220

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (localhost:root): user1 #使用LDAP用戶登錄

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

默認對實體用戶沒有限制,想讓用戶不能訪問那個目錄以外的目錄,則把用戶寫

/etc/vsftpd/chroot_list 文件裏面這裏想讓jack這個用戶只能訪問/home/pub

目錄,不能訪問其他目錄:

echo "jack" >/etc/vsftpd/chroot_list

ftp localhost

 匿名登錄者設置

CentOS默認的匿名根目錄在/var/ftp中,並且匿名在使用FTP服務時,默認可以使用

ftp用戶的權限,只是被chroot/var/ftp.

 編輯配置文件:

vi /etc/vsftpd/vsftpd.conf

#Anonymous Users

anonymous_enable=YES

no_anon_password=YES

anon_max_rate=50000

data_connection_timeout=60

idle_session_timeout=600

#匿名進行上傳/下載目錄

write_enable=YES

anon_other_write_enable=YES

anon_mkdir_write_enable=YES

anon_upload_enable=YES

chown_uploads=YES

chown_username=root

#Local Users

local_enable=NO

#Host

use_localtime=YES

dirmessage_enable=YES

xferlog_enable=YES

connect_from_port_20=YES

xferlog_std_format=YES

pam_service_name=vsftpd

listen=YES

tcp_wrappers=YES

banner_file=/etc/vsftpd/welcome.txt

max_clients=50

max_per_ip=5

 進行測試

/etc/init.d/vsftpd restart

ftp localhost

Connected to test.com.

220-Welcome to my FTP Server

220

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (localhost:root): anonymous

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> ls

227 Entering Passive Mode (127,0,0,1,177,234)

150 Here comes the directory listing.

drwxr-xr-x 2 0 0 4096 May 25 2008 pub

3.配置匿名進行上傳和下載:

由於匿名用戶取得的身份是FTP,所以要想上傳文件到/var/ftp/upload,則:

 mkdir /var/ftp/upload

 chown ftp /var/ftp/upload

 ftp localhost

進行文件上傳測試,看是否可以上傳成功.

配置FTPS

配置過程

這裏再次描述下FTPS的作用:它其實就是在普通的FTP服務(端口21)裏面加入安全傳輸層(TLS-Transport Layer Security)以及安全套接層(SSL-Secure Sockets Layer)

生成自定義的安全證書:

root@test ~: openssl req -x509 -nodes -days 365 -newkey rsa:1024

-keyout /etc/vsftpd/vsftpd.pem -out /etc/vsftpd/vsftpd.pem

Generating a 1024 bit RSA private key

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

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

writing new private key to '/etc/vsftpd/vsftpd.pem'

-----

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]:SH

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

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

Organizational Unit Name (eg, section) []:

Common Name (eg, your name or your server's hostname) []:mkt

Email Address []:www.abc.com

vi /etc/vsftpd/vsftpd.conf

#anonymous

anonymous_enable=YES

#Local users

local_enable=YES

write_enable=YES

local_umask=022

local_root=/home/pub/

userlist_enable=YES

userlist_deny=YES

userlist_file=/etc/vsftpd/user_list

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list

#Host

dirmessage_enable=YES

xferlog_enable=YES

connect_from_port_20=YES

xferlog_std_format=YES

listen=YES

pam_service_name=vsftpd

userlist_enable=YES

tcp_wrappers=YES

banner_file=/etc/vsftpd/welcome.txt

local_max_rate=100000

max_clients=10

#FTP over SSL

rsa_cert_file=/etc/vsftpd/vsftpd.pem

ssl_enable=YES

force_local_logins_ssl=YES

force_local_data_ssl=YES

ssl_tlsv1=YES

ssl_sslv2=YES

ssl_sslv3=YES

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章