/#
 # =====================================================================================
 #
 #       Filename:  xx.c
 #
 #    Description: 
 #
 #        Version:  1.0
 #        Created:  2010年10月20日 22时16分05秒
 #       Revision:  none
 #       Compiler:  gcc
 #
 #         Author:  chen_baocheng (Richard), baoch8@163.com
 #        Company:  RYOYO
 #
 # =====================================================================================
 #/
[root@RHCE ~]# rpm -qa | grep vsftpd
[root@RHCE ~]# mount /dev/cdrom-hda /mnt
mount: block device /dev/cdrom-hda is write-protected, mounting read-only
[root@RHCE ~]# cp /mnt/Server/vsftpd-2.0.5-16.el5.i386.rpm /
[root@RHCE ~]# chmod 755 /vsftpd-2.0.5-16.el5.i386.rpm
[root@RHCE ~]# rpm -ivh /vsftpd-2.0.5-16.el5.i386.rpm
warning: /vsftpd-2.0.5-16.el5.i386.rpm: Header V3 DSA sign
Preparing...                ########################################### [100%]
   1:vsftpd                 ########################################### [100%]
#如果这个时候你希望只是想做匿名下载的话,那么,基本上默认的配置文件已经满足你的需求了。

#如果希望在这里使用系统账户登陆的话,只需要增加账户就行了。
#例如:有三个用户,chen bao cheng 三个账户是系统账户,并且希望chen这账户可以使用FTP,并且它在上传与下载时,将速度限制成10KB/s
#1、建立三个账户,并设置密码,并将shell设置成nologin.修改/etc/vsftpd/ftpusers文件,加入bao cheng这两个账户。
#确保/etc/vsftp/vsftpd.conf里的local_enable=YES.因为local_root没有设置,所以chen登入后,会进入其家目录!
#以下为配置文件
# Example config file /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
idle_session_timeout=600
data_connection_timeout=120
ftpd_banner=Welcome to blah
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
local_max_rate=10000
#测试,先在chen的用户里建立一个文件,并测试。
[root@OS ~]# ftp 192.168.10.188
Connected to 192.168.10.188.
220 Welcome to blah FTP service.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
me (192.168.10.188:root): chen
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,10,188,246,92)
150 Here comes the directory listing.
 -rw-r--r--    1 0        0               0 Oct 20 23:04 123
226 Directory send OK.
ftp> get phlinux10all.tar.gz
local: phlinux10all.tar.gz remote: phlinux10all.tar.gz
227 Entering Passive Mode (192,168,10,188,122,23)
150 Opening BINARY mode data connection for phlinux10all.tar.gz (2970276 bytes).
226 File send OK.
2970276 bytes received in 2.9e+02 seconds (10 Kbytes/s)ame (192.168.10.188:root): chen
[root@OS Desktop]# ftp 192.168.10.188
Connected to 192.168.10.188.
220 Welcome to blah FTP service.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (192.168.10.188:root): bao
331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
2、虚拟用户的部分
#有10个用户,一部分为VIP的客户,一部分是公共用户。
[root@RHCE /]# rpm -ivh db4*
warning: db4-java-4.3.29-10.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:db4-utils              ########################################### [ 33%]
   2:db4-java               ########################################### [ 67%]
   3:db4-tcl                ########################################### [100%]
[root@RHCE /]# rpm -qa | grep ^db4
db4-tcl-4.3.29-10.el5
db4-devel-4.3.29-10.el5
db4-utils-4.3.29-10.el5
db4-java-4.3.29-10.el5
db4-4.3.29-10.e
[root@RHCE /]# vim /etc/vsftpd/vuser.txt
[root@RHCE /]# db_load -T -t hash -f /etc/vsftpd/vuser.txt /etc/vsftpd/vuser.db
#cat /etc/pam.d/vsftpd
auth        required    /lib/security/pam_userdb.so     db=/etc/vsftpd/vuser
account     required    /lib/security/pam_userdb.so     db=/etc/vsftpd/vuser
设置对应的账户:
vip客户=vip    公共用户=pub
vip的账户有redhat, cisco
pub的账户有microsoft
[root@RHCE /]# useradd -s /sbin/nologin -d /var/ftp/vip vip
[root@RHCE /]# useradd -s /sbin/nologin -d /var/ftp/public pub
[root@RHCE /]# passwd vip
Changing password for user vip.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@RHCE /]# passwd pub
Changing password for user pub.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
将虚拟用户的配置文件放在vsftpd_user_conf里,并且每个虚拟用户对应一个文件
#/etc/vsftpd/vsftpd_user_conf/redhat
local_root=/var/ftp/vip
guest_enable=YES
guest_username=vip
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
anon_upload_enable=YES
anon_world_readable_only=NO
anon_max_rate=100000
#/etc/vsftpd/vsftpd_user_conf/microsoft
local_root=/var/ftp/vip
guest_enable=YES
guest_username=pub
anon_world_readable_only=NO
anon_max_rate=10000
#为了让虚拟用户能生效,需要添加以下记录
user_config_dir=/etc/vsftpd/vsftpd_user_conf
#如此以来,一个基础的FTP服务器做好了。


 ------------------------
更新:如果你要从虚拟用户转为实体用户,也就是说把虚拟用户功能取消了,直接使用实体用户。那么我们需要将虚拟用户的功能取消。
那么你需要注意的是关于vsftpd的验证,将之前的用于虚拟用户认证的数据库取消。否则你将无法成功登录。
-------------------------