安装vsftpd
 
 1.(可以登录http://vsftpd.beasts.org网站下载最新版本软件包)
 
2.编译源代码                  (可参考帮助文件INSTALL,或者参考README文件)
 
#tar  xvzf  vsftpd-2.2.0.tar.gz  (解压缩包)
 
#cd  vsftpd-2.2.0                   (进入解包后的vsftpd-2.2.0目录)
 
#make                                   (编译生成二进制数据)
 
#make install(进行安装,把make生成的二进制文件拷贝到各目录。如:vsftpd 拷到 /usr/local/sbin/vsftpd;或者是 /usr/sbin/vsftpd;
 
ps#which  vsftpd                   (查看vsftpd文件安装到哪个目录)
 
3.安装配置文件
 
#cp  vsftpd.conf   /etc/            vsftpd.conf是配置文件)
 
#cp  RedHat/vsftpd.pam   /etc/pam.d/ftp*.pam文件是客户认证模块,对用户进行身份识别,ftpvsftp下默认的,不能改为其它文件名)
 
#mkdir /var/ftp                         (建立ftp服务器的home目录)
 
#chown  root.root  /var/ftp      (将ftp的拥有者和组均改为root
 
#chmod  og-w  /var/ftp            (将组和other的写权限去掉)
 
ps:此时的当前目录还是解压缩包后进入的vsftp-2.2.0目录。
 
4.编辑配置文件 /etc/vsftpd.conf
 
#vi /etc/vsftpd.conf
 
vsftpd.conf文件中修改或追加   listen=YES    (让服务器自己监听),保存退出。
 
5.启动服务器
 
#/usr/local/sbin/vsftpd &   (手动启动服务器,并让其工作在后台)
 
6.测试服务器的运行
 
#netstat -tnl(检查一下,看机器有没有开端口是21的服务器,结果如下)
 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State     
tcp        0      0 0.0.0.0:32768               0.0.0.0:*                   LISTEN     
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:32785             0.0.0.0:*                   LISTEN     
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:5335              0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN     
tcp        0      0 :::22                       :::*                        LISTEN     
 
[root@localhost vsftpd-2.2.0]# ftp localhost
Connected to localhost.localdomain.
220 localhost.localdomain FTP server (Version 5.60) ready.
334 Using authentication type GSSAPI; ADAT must follow
GSSAPI accepted as authentication type
GSSAPI error major: Miscellaneous failure
GSSAPI error minor: No credentials cache found
GSSAPI error: initializing context
GSSAPI authentication failed
334 Using authentication type KERBEROS_V4; ADAT must follow
KERBEROS_V4 accepted as authentication type
Kerberos V4 krb_mk_req failed: You have no tickets cached
Name (localhost:root): anonymous                   匿名身份登录)
331 Guest login ok, send ident as password.
Password:                                                         (密码为空)
230 Guest login ok, access restrictions apply.  (登录成功)
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd                                                      (显示当前目录)
257 "/" is current directory.   (当前目录为ftp服务器的根目录,是chroot后的根目录环境。该目录实际是/var/ftp)
ftp> ls(内容为空,匿名用户只能看到自己的文件或公开命名文件,/var/ftp目录下的root.root所有文件都看不到)
227 Entering Passive Mode (127,0,0,1,128,69)
150 Opening ASCII mode data connection for /bin/ls.
226 Transfer complete.
ftp> quit                                (退出,到此一个服务器就配置成功了)
421 Timeout (900 seconds): closing control connection.
[root@localhost vsftpd-2.2.0]#
 
7.修改服务器自动运行脚本
 
[root@localhost vsftpd-2.2.0]# vi  /etc/rc.local       (让电脑开机自动启动vsftp服务器)
 
进入rc.local 脚本文件
 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
 
touch /var/lock/subsys/local
 
/usr/local/sbin/vsftpd &                    (该行是我们自己追加的)