1.安装FTP服务器
#rpm -qa|grep vsftpd
#rpm -qa|grep vsftpd
2.启动FTP服务器
# /sbin/service vsftpd start
# /sbin/service vsftpd start
3.在/var/ftp/pub目录下创建一个名为test.txt的文件
文件内容为“This is a test file”。
文件内容为“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客户端登录到本地服务器,然后以匿名身份(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)
drwxr-xr-x 2 0 0 4096 Dec 04 01:35 pub
226 Directory send OK.
切换到pub目录下,并显示目录内容,可以找到刚才创建的文件test.txt:
227 Entering Passive Mode (127,0,0,1,63,15)
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文件:
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已成功下载到本机。
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
尝试上传名为123.txt的文件,可以看到请求被拒绝了。
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
尝试上传名为123.txt的文件,可以看到请求被拒绝了。
ftp> put 123.txt
local: ylg.txt remote: 123.txt
227 Entering Passive Mode (127,0,0,1,243,10)
550 Permission denied.
退出登录:
ftp> bye
221 Goodbye.
local: ylg.txt remote: 123.txt
227 Entering Passive Mode (127,0,0,1,243,10)
550 Permission denied.
退出登录:
ftp> bye
221 Goodbye.