CentOS 6.3下vsftpd的簡單使用教程

來源:互聯網
上載者:User

CentOS 6.3下vsftpd的簡單使用教程

 

1、關於vsftpd的基本知識

(1)什麼是vsftpd。參考百度百科,http://baike.baidu.com/view/1806035.htm

(2)FTP使用者的3種身份:實體使用者(real user)、訪客(guest)和匿名登入者(anonymous)

a. 實體使用者(real user):一般是Linux系統上的使用者,也是FTP使用者,登入FTP要求輸入密碼

b. 訪客(guest):不是Linux系統的使用者,而是FTP使用者,登入FTP要求輸入密碼

c. 匿名登入者(anonymous):不是Linux系統的使用者,而是FTP使用者,登入FTP不要求輸入密碼

 

2. 安裝vsftpd

[root@localhost ~]# yum install vsftpd

 

3、啟動vsftpd服務

[root@localhost ~]# service vsftpd startStarting vsftpd for vsftpd:                                [  OK  ][root@localhost ~]# service vsftpd statusvsftpd (pid 30196) is running...

在Chrome中開啟ftp://主機IP,該網路地址預設指向的是/var/ftp目錄,如下


4、vsftpd的軟體組織

/etc/vsftpd/vsftpd.conf

主設定檔

/usr/sbin/vsftpd

vsftpd的可執行檔

/etc/rc.d/init.d/vsftpd

啟動指令碼

/etc/pam.d/vsftpd

PAM認證檔案

/etc/vsftpd/ftpusers

禁止使用vsftpd的使用者列表檔案

/etc/vsftpd/user_list

禁止或允許使用vsftpd的使用者列表

/var/ftp

匿名使用者主目錄

/var/ftp/pub

匿名使用者的下載目錄

 

5、分析和修改/etc/vsftpd/vsftpd.conf檔案

(1)先備份vsftpd.conf檔案

[root@localhost ~]# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.backup

 

(2)查看vsftpd的版本和vsftpd.conf檔案的配置說明

[root@localhost ~]# vsftpd -vvsftpd: version 2.2.2[root@localhost ~]# man vsftpd.conf

 

(3)預設vsftpd.conf檔案的配置(刪除了多餘的注釋)

[root@localhost ~]# cat -n /etc/vsftpd/vsftpd.conf     1anonymous_enable=YES     2local_enable=YES     3write_enable=YES     4local_umask=022     5dirmessage_enable=YES     6xferlog_enable=YES     7connect_from_port_20=YES     8xferlog_std_format=YES     9listen=YES    10pam_service_name=vsftpd    11userlist_enable=YES    12tcp_wrappers=YES[root@localhost ~]#

以上預設配置實現如下的功能:

a. 可以使用anonymous這個匿名帳號或其他實體帳號(/etc/passwd)登入

b. anonymous的預設目錄在/var/ftp,且無上傳許可權,也已經被chroot了

c. 實體使用者的預設目錄參考/etc/passwd,並沒有被chroot,可前往任何有許可權即可進入的目錄中

d. 任何於/etc/vsftpd/ftpusers記憶體在的帳號均無法使用vsftpd

e. 可利用/etc/host.{allow|deny}來作為基礎防火牆

f. 當用戶端有任何上傳/下載資訊時,該資訊會被記錄到/var/log/vsftpd.log中

g. 主動式串連的連接埠為20

h. 使用格林威治時間(GMT)

(參考鳥哥的私房菜^_^)

 

(4)我的個人修改(在預設的基礎上),如下

[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf# The default settings created by vsftpdanonymous_enable=YESlocal_enable=YESwrite_enable=YESlocal_umask=002dirmessage_enable=YESxferlog_enable=YESconnect_from_port_20=YESxferlog_std_format=YESlisten=YESpam_service_name=vsftpduserlist_enable=YEStcp_wrappers=YES# ---Added by wesley---# Use local timeuse_localtime=YES# Welcome informationbanner_file=/etc/vsftpd/welcome.txt# Enable chroot and locate chroot_list filechroot_list_enable=YESchroot_list_file=/etc/vsftpd/chroot_list# Make all real users chroot and let users in chroot_list not be chroot# If comment the line, the users in chroot_list will be chroot (It's tricky!)chroot_local_user=YES# Defeine maximum clients to use ftpmax_clients=10# Define maximum connections per ip addressmax_per_ip=5# Relocate real users' ftp homes to specific folders# By default, real users' ftp homes is /home/<username>user_config_dir=/etc/vsftpd/userhomes# ---End---

(a)use_localtime=YES:使用本地時間。

(b)chroot_list_enable=YES:啟用chroot,使用者登入將鎖定其ftp主目錄,不能切換到其他目錄。

(c)chroot_list_file=/etc/vsftpd/chroot_list:當只有chroot_local_user=NO(或者沒有這一行時),在chroot_list檔案(需要手動建立)中的使用者,是被chroot的,使用者登入將鎖定其ftp主目錄;而chroot_local_user=YES,在chroot_list檔案中的使用者,是不被chroot的,使用者登入後可以任意切換目錄。

(d)chroot_local_user=YES:YES或NO時,觸發chroot_list中的使用者允許或不允許chroot。

(e)max_clients=10:限制FTP串連數最大為10

(f)max_per_ip=5:限制每個IP最多使用5個FTP串連

(g)user_config_dir=/etc/vsftpd/userhomes,自訂一個使用者配置目錄,該目錄存放每個實體使用者(real user)的使用者名稱命名的檔案,例如/etc/vsftpd/userhomes目錄下建立一個test檔案,當然test使用者是存在的,在test檔案中寫入一行local_root=/var/ftp/pub,那麼test使用者登入FTP時,ftp主目錄自動定位到/var/ftp/pub,而不是原來的/home/test。

(h)local_umask=002:當FTP使用者建立檔案或檔案夾時,要用到該umask值。這裡比預設的配置,增加了組使用者寫入權限。

 

參考資料:

1、http://blog.csdn.net/kofterry/article/details/4277267

2、http://os.51cto.com/art/201004/192447.htm

3、http://tanjunjie.blog.51cto.com/6988/774256

4、http://desert3.iteye.com/blog/1685734

5、http://www.cnblogs.com/redhatlinux/archive/2012/04/18/2455737.html

6、http://crazyidea.iteye.com/blog/1207952

7、http://book.51cto.com/art/201005/199774.htm

8、《鳥哥的Linux私房菜:伺服器架設篇(第二版)》,P631

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.