#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
將其改爲:
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
新增一個文件/etc/vsftpd/chroot_list,文件內容爲兩個用戶名:
ylg
user1
5.針對不同的使用者限制不同的速度。假設用戶ylg所能使用的最高速度爲500Kb/s,用戶user1所能使用的最高速度爲250Kb/s,可以通過以下方法設置。在/etc/vsftpd/vsftpd.conf文件尾部新增以下一行:
user_config_dir=/etc/vsftpd/userconf
增加一個名爲/etc/vsftpd/userconf的目錄:
#mkdir /etc/vsftpd/userconf
在/etc/vsftpd/userconf下新增一個名爲ylg的文件,其內容如下所示:
local_max_rate=500000
在/etc/vsftpd/userconf目錄下新增一個名爲user1的文件,其內容如下所示:
local_max_rate=250000
VSFTP對於速度的限制範圍大概在80%到120%之間,也就是限制最高速度爲100Kb/s,但實際的速度可能在80Kb/s到120Kb/s之間。如果頻寬不足,數值會低於此限制。
6.對於每一個聯機用戶,都以獨立的進程來運行。一般情況下,在啓動VSFTP時,只會看到一個名爲vsftpd的進程在運行。但若是讀者希望每一個聯機用戶都能以獨立的進程來呈現,則可通過在/etc/vsftpd/vsftpd.conf文件中增加以下一行來實現:
setproctitle_enable=YES
7.保存/etc/vsftpd/vsftpd.conf文件,然後重新啓動vsftpd:
#service vsftpd restart
8.測試剛創建的FTP服務器。
以缺省方式登錄會被拒絕,因爲此時的默認端口號已經更改爲2121,所以登錄時需指定端口。
# ftp 127.0.0.1
ftp: connect: Connection refused
此時也不能再使用匿名方式登錄:
# ftp 127.0.0.1 2121
Connected to 127.0.0.1 (127.0.0.1)。
220 (vsFTPd 1.1.3)
Name (127.0.0.1:root): anonymous
331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
如果以用戶ylg則可以成功登錄(指定端口2121),並顯示歡迎信息:
# ftp 127.0.0.1 2121
Connected to 127.0.0.1 (127.0.0.1)。
220 (vsFTPd 1.1.3)
Name (127.0.0.1:root): ylg
331 Please specify the password.
Password:
230-歡迎來到我的FTP站點
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
因爲在設置中設定了不能切換目錄,所以下列命令無法正確執行:
ftp》 cd /home
550 Failed to change directory.
再來測試一下上傳和下載。首先下載服務器目錄中的test.txt文件:
ftp》 get test.txt
local: test.txt remote: test.txt
227 Entering Passive Mode (127,0,0,1,243,215)
150 Opening BINARY mode data connection for test.txt (21 bytes)。
226 File send OK.
21 bytes received in 0.00308 secs (6.7 Kbytes/sec)
可以通過!ls命令看到本機目錄中已成功下載該文件。然後上傳本機目錄中的ylg.txt文件到服務器:
ftp》 put ylg.txt
local: ylg.txt remote: ylg.txt
227 Entering Passive Mode (127,0,0,1,133,248)
150 Ok to send data.
226 File receive OK.
19 bytes sent in 0.0401 secs (0.46 Kbytes/sec)
用ls命令查看服務器目錄,會發現該文件已成功上傳。