您的位置:首页 > 编程语言 > PHP开发

用vsftp快速搭建ftp服务器教程指南

2007-07-03 11:10 806 查看
用vsftp快速搭建ftp服务器教程指南

1、  下载源码到服务器,其下载地址是ftp://vsftpd.beasts.org/users/cevans/,当前的版本是vsftpd-2.0.5.tar.gz 。强烈建议使用源码安装,即可摆脱类似rpm包依赖的困惑,又可以实现在不同unix/linux下自如的工作。
2、  解压安装:
        tar zxvf vsftpd-2.0.5.tar.gz ; cd vsftp-2.0.5; make; make install

3、  添加ftp的用户,如果用户数目不多,简单些,用系统用户吧。Useradd –d /home/sery sery ;passwd ******.
4、   拷贝配置文件,这里有2个:
    Cp vsftpd.conf /etc/vsftpd.conf
    cp Redhat/vsftpd.pam  /etc/pam.d/ftp

不拷贝vsftpd.pam这个文件,将导致ftp用户不能登陆的问题。这个文件在debian下也是可以的。
5、  修改配置文件/etc/vsftpd.conf。这个配置文件是vsftpd的关键所在,修改下列值,以实现不同的功能: 字串2
(1)    修改的部分:
    把
    local_enable=yes
    write_enable=yes
    local_umask=022
前面的注释取消。

(2)    增加部分:
        listen=YES(ftp作为独立的守护进程)
        chroot_local_user=yes(用户被定位在自己的主目录里,用cd / 并不能切换到根目录)
          
cmds_allowed=ABOR,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,
PORT,PWD,QUIT,RETR,RMD,RNFR,RNTO,SITE,SIZE,STOR,TYPE,USER,
ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST(只许上传文件和目录,但不许删除。注意:这些必须一行写完)
6、  启动ftp服务:
    Vsftpd&
 
说明:配置文件vsftpd.conf 每行前不能有空白,必须顶格书写,否则运行失败。

pam_service_name=vsftpd
补充说明一下pam_service_name这个配置语句,在debian下是很邪门的,需要给出绝对路径,这个绝对路径一般是 /etc/pam.d/vsftpd。如果你的合法可以访问FTP的本地用户无法登录FTP时候无法进行身份验证很可能就是这个pam的绝对路径问题。

vsftpd.conf:
# Example config file /etc/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? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# 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
#
# 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
#
# 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
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_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=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# 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=ftpsecure
#
# 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
#
# 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 on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# 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
#
# 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

listen=YES
chroot_local_user=yes

cmds_allowed=ABOR,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RETR,RMD,RNFR,RNTO,SITE,SIZE,STOR,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息