转自http://www.cosdiv.com/page/M0/S219/219630.html
vsftpd安装在as5下,安装包为:vsftpd-2.0.5-16.el5_4.1.i386.rpm
1、vi /etc/vsftpd/vsftpd.conf 增加一行
chroot_local_user=YES
#limit user only accessc its own directory.
2、重启启动vsftpd服务
# /etc/init.d/vsftpd restart
备注:重启服务之后,FTP所有用户都将受限制只能访问他们home目录的文件
附:/etc/vsftpd/vsftpd.conf的配置说明(转载)
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd"s
# capabilities.
#
# Allow anonymous FTP?
anonymous_enable=NO 是否允许匿名ftp,如否则选择NO
# Uncomment this to allow local users to log in.
local_enable=YES 是否允许本地用户登录
# Uncomment this to enable any form of FTP write command.
write_enable=YES 开放本地用户的写权限,这个选项可以控制FTP 的指令是否允许更改file system,譬如STOR、DELE、RNFR、RNTO、MKD、RMD、APPE 以及SITE。预设是关闭。
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd"s)
local_umask=022 默认的umask码,设置本地用户的文件生成掩码为022,默认值为077。
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES 是否允许匿名上传文件
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES 是否允许匿名用户有创建目录的权利
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
#dirmessage_enable=YES 是否显示目录说明文件,默认是YES但需要手工创建.message文件
# Activate logging of uploads/downloads.
xferlog_enable=YES 是否记录ftp传输过程,如果启动,上传与下载的信息将被完整纪录在底下xferlog_file 所定义的档案中。预设为开启。
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES 启用FTP数据端口的连接请求,若设为YES,则强迫ftp-data 的数据传送使用port 20。默认值为YES。
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
chown_uploads=YES 若是启动,所有匿名上传数据的拥有者将被更换为chown_username 当中所设定的使用者。这样的选项对于安全及管理,是很有用的。默认值为NO。
chown_username=whoever 这里可以定义当匿名登入者上传档案时,该档案的拥有者将被置换的使用者名称。预设值为root。
# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/vsftpd.log ftp传输日志的路径和名字默认是/var/log/vsftpd.log
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES 是否使用标准的ftp xferlog模式
# You may change the default value for timing out an idle session.
idle_session_timeout=600 设置默认的断开不活跃session的时间
# You may change the default value for timing out a data connection.
data_connection_timeout=120 设置数据传输超时时间
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
nopriv_user=nobody 运行vsftpd需要的非特权系统用户默认是nobody
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
async_abor_enable=YES 是否允许运行特殊的ftp命令async
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that turning on ascii_download_enable enables malicious remote parties
# to consume your I/O resources, by issuing the command "SIZE /big/file" in
# ASCII mode.
# These ASCII options are split into upload and download because you may wish
# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
# on the client anyway..
#ascii_upload_enable=YES
#ascii_download_enable=YES
是否使用ascii码方式上传和下载文件
# You may fully customise the login banner string:
ftpd_banner=Welcome to blah FTP service. 定制欢迎信息
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
是否允许禁止匿名用户使用某些邮件地址,如果是,输入禁止的邮件地址的路径和文件名
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list
如果启动这项功能,则所有的本机使用者登入均可进到根目录之外的数据夹,除了列
在/etc/vsftpd.chroot_list 之中的使用者之外。默认值为NO。
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES 若是启动此功能,则允许登入者使用ls -R 这个指令。默认值为NO。
pam_service_name=vsftpd 设置PAM认证服务的配置文件名称,该文件存放 在/etc/pam.d/目录下
userlist_enable=YES
若是启动此功能,则会读取/etc/vsftpd.user_list 当中的使用者名称。此项功能可以在询问密码前就出现失败讯息,而不需要检验密码的程序。默认值为关闭。
userlist_deny=NO
这个选项只有在userlist_enable 启动时才会被检验。如果将这个选项设为YES,则在/etc/vsftpd.user_list 中的使用者将无法登入﹔ 若设为NO , 则只有在 /etc/vsftpd.user_list 中的使用者才能登入。而且此项功能可以在询问密码前就出现错误讯息,而不需要检验密码的程序。
#enable for standalone mode
listen=YES
是启动,则vsftpd 将会以独立运作的方式执行,若是vsftpd 独立执行,如RedHat9的默认值,则必须启动﹔若是vsftpd 包含在xinetd 之中,则必须关闭此功能,如RedHat8。在RedHat9 的默认值为YES。
tcp_wrappers=YES 将vsftpd 与TCP_wrapper 结合。如果启动,则会将vsftpd 与tcp wrapper 结合,也就是可以在/etc/hosts.allow与/etc/hosts.deny 中定义可联机或是拒绝的来源地址。
本文转自holy2009 51CTO博客,原文链接:http://blog.51cto.com/holy2010/405128