- 安装:#>rpm -ivh vsftpd.rpm,默认安装在/etc/vsftpd目录下面
- 配置vsftpd.conf文件,配置如下:
# Example config file /etc/vsftpd/vsftpd.conf
#
#Thedefaultcompiledinsettingsarefairlyparanoid.Thissamplefile
#loosensthingsupabit,tomaketheftpdaemonmoreusable.
#Pleaseseevsftpd.conf.5forallcompiledindefaults.
#
#READTHIS:ThisexamplefileisNOTanexhaustivelistofvsftpdoptions.
#Pleasereadthevsftpd.conf.5manualpagetogetafullideaofvsftpd's
#capabilities.
#
#AllowanonymousFTP?(Beware-allowedbydefaultifyoucommentthisout).
#anonymous_enable=YES
anonymous_enable=NO
#
#Uncommentthistoallowlocaluserstologin.
local_enable=YES
#
#UncommentthistoenableanyformofFTPwritecommand.
write_enable=YES
#
#Defaultumaskforlocalusersis077.Youmaywishtochangethisto022,
#ifyourusersexpectthat(022isusedbymostotherftpd's)
local_umask=022
#
#UncommentthistoallowtheanonymousFTPusertouploadfiles.Thisonly
#hasaneffectiftheaboveglobalwriteenableisactivated.Also,youwill
#obviouslyneedtocreateadirectorywritablebytheFTPuser.
#anon_upload_enable=YES
#
#UncommentthisifyouwanttheanonymousFTPusertobeabletocreate
#newdirectories.
#anon_mkdir_write_enable=YES
#
#Activatedirectorymessages-messagesgiventoremoteuserswhenthey
#gointoacertaindirectory.
dirmessage_enable=YES
#
#Thetargetlogfilecanbevsftpd_log_fileorxferlog_file.
#Thisdependsonsettingxferlog_std_formatparameter
xferlog_enable=YES
#
#MakesurePORTtransferconnectionsoriginatefromport20(ftp-data).
connect_from_port_20=YES
#
#Ifyouwant,youcanarrangeforuploadedanonymousfilestobeownedby
#adifferentuser.Note!Using"root"foruploadedfilesisnot
#recommended!
#chown_uploads=YES
#chown_username=whoever
#
#Thenameoflogfilewhenxferlog_enable=YESandxferlog_std_format=YES
#WARNING-changingthisfilenameaffects/etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
#Switchesbetweenloggingintovsftpd_log_fileandxferlog_filefiles.
#NOwritestovsftpd_log_file,YEStoxferlog_file
xferlog_std_format=YES
#
#Youmaychangethedefaultvaluefortimingoutanidlesession.
#idle_session_timeout=600
#
#Youmaychangethedefaultvaluefortimingoutadataconnection.
#data_connection_timeout=120
#
#Itisrecommendedthatyoudefineonyoursystemauniqueuserwhichthe
#ftpservercanuseasatotallyisolatedandunprivilegeduser.
#nopriv_user=ftpsecure
#
#EnablethisandtheserverwillrecogniseasynchronousABORrequests.Not
#recommendedforsecurity(thecodeisnon-trivial).Notenablingit,
#however,mayconfuseolderFTPclients.
#async_abor_enable=YES
#
#BydefaulttheserverwillpretendtoallowASCIImodebutinfactignore
#therequest.TurnonthebelowoptionstohavetheserveractuallydoASCII
#manglingonfileswheninASCIImode.
#BewarethatonsomeFTPservers,ASCIIsupportallowsadenialofservice
#attack(DoS)viathecommand"SIZE/big/file"inASCIImode.vsftpd
#predictedthisattackandhasalwaysbeensafe,reportingthesizeofthe
#rawfile.
#ASCIImanglingisahorriblefeatureoftheprotocol.
ascii_upload_enable=YES
ascii_download_enable=YES
#
#Youmayfullycustomisetheloginbannerstring:
#ftpd_banner=WelcometoblahFTPservice.
#
#Youmayspecifyafileofdisallowedanonymouse-mailaddresses.Apparently
#usefulforcombattingcertainDoSattacks.
#deny_email_enable=YES
#(defaultfollows)
#banned_email_file=/etc/vsftpd/banned_emails
#
#Youmayspecifyanexplicitlistoflocaluserstochroot()totheirhome
#directory.Ifchroot_local_userisYES,thenthislistbecomesalistof
#userstoNOTchroot().
chroot_local_user=YES(设置所有用户都定位到自己的home目录下面,不能进到父目录里面,如果这个地方设置为YES,chroot_list_enable=YES的话,就只有chroot_list文件里面的用户可以进到父目录)
#chroot_list_enable=NO
#(defaultfollows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
#Youmayactivatethe"-R"optiontothebuiltinls.Thisisdisabledby
#defaulttoavoidremoteusersbeingabletocauseexcessiveI/Oonlarge
#sites.However,somebrokenFTPclientssuchas"ncftp"and"mirror"assume
#thepresenceofthe"-R"option,sothereisastrongcaseforenablingit.
#ls_recurse_enable=YES
#
#When"listen"directiveisenabled,vsftpdrunsinstandalonemodeand
#listensonIPv4sockets.Thisdirectivecannotbeusedinconjunction
#withthelisten_ipv6directive.
listen=YES
#
#ThisdirectiveenableslisteningonIPv6sockets.TolistenonIPv4andIPv6
#sockets,youmustruntwocopiesofvsftpdwhithtwoconfigurationfiles.
#Makesure,thatoneofthelistenoptionsiscommented!!
#listen_ipv6=YESpam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YESuserlist_enable=YES(设置只有列表里面的用户可以登录)
userlist_deny=NO(设置是否显示登录框)
userlist_file=/etc/vsftpd/vsftpd.user_list(用户文件,一行一个用户,可以是系统用户)local_root=/home/gomye/apache-tomcat-6.0.32(所有ftp用户的根目录)
- 在/etc/vsftpd目录中新建文件,并添加用户,即写入一行,gomye(这是系统中的用户,)
- 重启#>service vsftpd restart,这个时候通过客户端访问,有可能会出现500错误,或者没有任何显示也不报错,这样的情况要考虑是否是Selinux的原因,需要关闭,执行#>setenforce 0关闭
- 参考网站:http://bevisoft.iteye.com/blog/423751
注意:
- 如果有多个用户,且多个用户的根目录都不一样,则需要另外配置,
- 1.在vsftpd.conf文件里面加入一项:
user_config_dir=/etc/vsftpd/user_conf(设置多用户虚拟目录的配置文件存放位置)
然后在/etc/vsftpd/目录下面再建一个user_conf的目录
在里面新建一个gomye的文件(记住这个文件的名字要跟登录ftp用户的名字一样)
在gomye文件里面输入一行:
local_root=/opt(把gomye用户的根目录定位到/opt下面)