ftp工作是會(huì)啟動(dòng)兩個(gè)通道:
控制通道 , 數(shù)據(jù)通道
在ftp協(xié)議中,控制連接均是由客戶端發(fā)起的,而數(shù)據(jù)連接有兩種模式:port模式(主動(dòng)模式)和pasv(被動(dòng)模式)
PORT模式:
在客戶端需要接收數(shù)據(jù)時(shí),ftp_client(大于1024的隨機(jī)端口)-PORT命令->ftp_server(21) 發(fā)送PORT命令,這個(gè)PORT命令包含了客戶端是用什么端口來接收數(shù)據(jù)(大于1024的隨機(jī)端口),在傳送數(shù)據(jù)時(shí),ftp_server將通過自己的TCP 20 端口和PORT中包含的端口建立新的連接來傳送數(shù)據(jù)。
PASV模式:
傳送數(shù)據(jù)時(shí),ftp_client--PASV命令-->ftp_server(21) 發(fā)送PASV命令時(shí),ftp_server自動(dòng)打開一個(gè)1024--5000之間的隨機(jī)端口并且通知ftp_client在這個(gè)端口上傳送數(shù)據(jù),然后客戶端向指定的端口發(fā)出請求連接,建立一條數(shù)據(jù)鏈路進(jìn)行數(shù)據(jù)傳輸。
安裝ftp
#rpm -qa vsftpd 查看是否已經(jīng)安裝
#yum install -y vsftpd
#rpm -ql vsftpd
/etc/logrotate.d/vsftpd. vsftpd的日志文件
/etc/pam.d/vsftpd PAM認(rèn)證文件
/etc/rc.d/init.d/vsftpd 啟動(dòng)腳本
/etc/vsftpd vsftpd的配置文件存放的目錄
/etc/vsftpd/ftpusers 禁止使用vsftpd的用戶列表文件
/etc/vsftpd/user_list 禁止或允許使用vsftpd的用戶列表文件
/etc/vsftpd/vsftpd.conf 主配置文件
/etc/vsftpd/vsftpd_conf_migrate.sh vsftpd操作的一些變量和設(shè)置
/usr/sbin/vsftpd vsftpd的主程序
其他一些說明文檔和手冊文件略!
/var/ftp 匿名用戶主目錄
/var/ftp/pub 匿名用戶的下載目錄
#service vsftpd start
#chkconfig --level vsftpd
#chkconfig --level 2345 vsftpd on
2 匿名用戶的登錄名:ftp(anonymous) 密碼空 ,登錄的目錄為/var/ftp
用匿名用戶登錄的時(shí)候默認(rèn)是只有下載的權(quán)限,沒有上傳,創(chuàng)建和刪除的權(quán)限:
#vim /etc/vsftpd/vsftpd.conf
anon_upload_enable=YES 上傳
anon_mkdir_write_enable=YES 創(chuàng)建
anon_other_write_enable=YES 刪除
#service vsftpd restart
為了安全應(yīng)該禁止匿名用戶的登錄:
123456 #vim /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
#anon_upload_enable=YES 上傳
#anon_mkdir_write_enable=YES 創(chuàng)建
#anon_other_write_enable=YES 刪除
#service vsftpd restart
3 創(chuàng)建一個(gè)直接登錄系統(tǒng)用戶來登錄ftp:
#useradd -s /sbin/nologin viong
#passwd viong
用戶具有 上傳 創(chuàng)建 下載 切換目錄
------------------------------------------------------------------
4 加強(qiáng)vsftp安全設(shè)置:
限制系統(tǒng)用戶鎖定在家目錄:
#vim /etc/vsftpd/vsftpd.conf
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list 限制更多的系統(tǒng)用戶,把需要限制的用戶加入/etc/vsftpd/chroot_list中即可
#touch /etc/vsftpd/chroot_list
#cut -d: -f 1 /etc/passwd >>/etc/vsftpd/chroot_list 將本地用戶都加入到chroot_list
限制重要系統(tǒng)用戶不能登錄ftp:
#cat /etc/vsftpd/ftpusers 默認(rèn)已經(jīng)添加了系統(tǒng)中一些比較重要的用戶
#echo "viong" >>/etc/vsftpd/ftpusers 此時(shí)viong不能登錄ftp
利用ftp用戶策略允許登錄ftp的系統(tǒng)用戶:
/etc/vsftpd/user_list 只有在這個(gè)文件中的用戶才能登錄系統(tǒng):
#vim /etc/vsftpd/vsftpd.conf
#在userlist_enable=YES 的后面添加
userlist_deny=NO
userlist_file=/etc/vsftpd/user_list
設(shè)置登錄ftp目標(biāo)ip地址:用iptables設(shè)置
---------------------------------------
搭建支持SSL加密傳輸?shù)膙sftpd:
#openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /etc/vsftpd/vsftpd.pem -out /etc/vsftpd/vsftpd.pem 生成證書
#vim /etc/vsftpd/vsftpd.conf
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=YES
ssl_sslv3=YES
rsa_cert_file=/etc/vsftpd/vsftpd.pem
下面是ssl參數(shù)一些定義,根據(jù)自己需求去修改:
ssl_enable=yes/no //是否啟用 SSL,默認(rèn)為no
allow_anon_ssl=yes/no //是否允許匿名用戶使用SSL,默認(rèn)為no
rsa_cert_file=/path/to/file //rsa證書的位置
dsa_cert_file=/path/to/file //dsa證書的位置
force_local_logins_ssl=yes/no //非匿名用戶登陸時(shí)是否加密,默認(rèn)為yes
force_local_data_ssl=yes/no //非匿名用戶傳輸數(shù)據(jù)時(shí)是否加密,默認(rèn)為yes
force_anon_logins_ssl=yes/no //匿名用戶登錄時(shí)是否加密,默認(rèn)為no
force_anon_data_ssl=yes/no //匿名用戶數(shù)據(jù)傳輸時(shí)是否加密,默認(rèn)為no
ssl_sslv2=yes/no //是否激活sslv2加密,默認(rèn)no
ssl_sslv3=yes/no //是否激活sslv3加密,默認(rèn)no
ssl_tlsv1=yes/no //是否激活tls v1加密,默認(rèn)yes
ssl_ciphers=加密方法 //默認(rèn)是DES-CBC3-SHA
#service vsftpd restart
用flashftp連接:
連接類型為:FTP使用公開SSL(驗(yàn)證SSL)
地址:192.168.137.130:21
登錄類型:普通
用戶:viong
密碼:123
ftp虛擬用戶請看:http://www.linuxidc.com/Linux/2015-06/118443.htm
玩轉(zhuǎn)vsftpd服務(wù)器的四大高級配置:http://www.linuxidc.com/Linux/2013-09/90565.htm
vsFTPd配置教程:http://www.linuxidc.com/Linux/2013-09/90562.htm
CentOS 7安裝配置FTP服務(wù)器 http://www.linuxidc.com/Linux/2014-11/109233.htm
Ubuntu實(shí)用簡單的FTP架設(shè) http://www.linuxidc.com/Linux/2012-02/55346.htm
Ubuntu 上架設(shè)FTP服務(wù)器和Apache服務(wù)器 http://www.linuxidc.com/Linux/2011-04/35295.htm
Ubuntu 13.04 安裝 LAMP\vsftpd\Webmin\phpMyAdmin 服務(wù)及設(shè)置 http://www.linuxidc.com/Linux/2013-06/86250.htm
RHEL6平臺(tái)下SeLinux和vsftpd的匿名上傳的簡單案例 http://www.linuxidc.com/Linux/2013-04/82300.htm
Linux系統(tǒng)vsftpd源碼安裝 http://www.linuxidc.com/Linux/2013-03/81475.htm
openSUSE 13.2/13.1 下安裝配置 FTP服務(wù)器 vsftpd http://www.linuxidc.com/Linux/2014-12/110070.htm