2024年4月16日发(作者:)

用Linux构建高效FTP服务器

快速构建FTP服务器

FTP服务器实现的基本功能是上传下载,下面就分几个步骤来搭建一个可以实现下载功

能的简易FTP服务器。

1.安装FTP服务器

如果在安装系统时没有选择安装FTP服务器,可以通过Red Hat 9.0中的“添加/删除应

用程序”工具进行安装。具体方法是,选择“主选单”→“系统设置”→“添加/删除应用程序”,

在弹出的界面中选中FTP服务器,单击“更新”即可。

如果无法确认是否安装了该软件,可以使用以下命令查看:

#rpm -qa|grep vsftpd

vsftpd-1.1.3-8

2.启动FTP服务器

套用Red Hat 9.0的预设范例直接启动VSFTP。

# /sbin/service vsftpd start

为vsftpd启动vsftpd: [确定]

3.在/var/ftp/pub目录下创建一个名为的文件,文件内容为“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目录下,并显示目录内容,可以找到刚才创建的文件:

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

226 Directory send OK.

下载文件:

ftp> mget

mget ? y

227 Entering Passive Mode (127,0,0,1,186,210)

150 Opening BINARY mode data connection for (21

bytes).

226 File send OK.

21 bytes received in 0.0108 secs (1.9 Kbytes/sec)