3.在/var/ftp/pub目录下创建一个名为test.txt的文件,文件内容为“This is a test file”。
4.测试
使用FTP客户端登录到本地服务器,然后以匿名身份(anonymous)登录:
# ftp 127.0.0.1
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:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
这样就成功地登录到FTP服务器。可以显示服务器目录列表如下:
ftp>; ls
227 Entering Passive Mode (127,0,0,1,63,15)
150 Here comes the directory listing.
drwxr-xr-x 2 0 0 4096 Dec 04 01:35 pub
226 Directory send OK.
切换到pub目录下,并显示目录内容,可以找到刚才创建的文件test.txt:
ftp>; cd pub
250 Directory successfully changed.
ftp>; ls
227 Entering Passive Mode (127,0,0,1,232,34)
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 21 Dec 04 01:35 test.txt
226 Directory send OK.
下载test.txt文件:
ftp>; mget test.txt
mget test.txt? y
227 Entering Passive Mode (127,0,0,1,186,210)
150 Opening BINARY mode data connection for test.txt (21 bytes).
226 File send OK.
21 bytes received in 0.0108 secs (1.9 Kbytes/sec)
查看本机目录内容,可以看到test.txt已成功下载到本机。
ftp>; !ls
a EIO_Binders initrd mnt proc tftpboot ylg.txt
bin etc lib mymnt root tmp
boot home lost+found myshare sbin usr
dev id_dsas.pub misc opt test.txt var
# 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,24
150 Ok to send data.
226 File receive OK.
19 bytes sent in 0.0401 secs (0.46 Kbytes/sec)
# ftp 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
220 Welcom to my FTP server.
Name (127.0.0.1:root): gou
331 Please specify the password.
Password:
230 Login successful. Have fun.
Remote system type is UNIX.
Using binary mode to transfer files.
测试下载服务器目录中的一个文件mytest:
ftp>; get mytest
local: mytest remote: mytest
227 Entering Passive Mode (127,0,0,1,159,19)
150 Opening BINARY mode data connection for mytest (21 bytes).
226 File send OK.
21 bytes received in 0.00038 secs (54 Kbytes/sec)
测试上传本机目录中的文件vsftpd.conf:
ftp>; !ls
account.db chroot_list k mytest userconf vsftpd.conf
ftp>; put vsftpd.conf
local: vsftpd.conf remote: vsftpd.conf
227 Entering Passive Mode (127,0,0,1,117,203)
150 Ok to send data.
226 File receive OK.
4229 bytes sent in 0.00195 secs (2.1e+03 Kbytes/sec)