配置VSFTPD的方法相关.doc_第1页
配置VSFTPD的方法相关.doc_第2页
配置VSFTPD的方法相关.doc_第3页
配置VSFTPD的方法相关.doc_第4页
配置VSFTPD的方法相关.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、首先查看系统是否已将安装了vsftp这个软件#rpm -qa |grep vsftpdvsftpd-1.1.3-8如果没有就找到RH9的第三张安装光盘,安装这个软件#rpm -ivh vsftpd-1.1.3-8.i386.rpm 2、启动、停止、重启vsftp服务器#/etc/rc.d/init.d/vsftpd start/stop/restart 3、开机时启动vsftp服务器(3种方法)方法一:#ntsysv 在终端输入ntsysv,利用上下方向键把光标移动到vsftp,在以空格选,最后利用Tab键把光标移动到确定,然后按enter就完成了。方法二:用图形化设置工具利用鼠标选择。主菜单-系统设置-服务器设置-服务选择vsftp,保存退出。方法三:#chkconfig -level 35 vsftpd on 35的意思就是在启动的时候图形和文本模式都开 4、测试vsftp服务器# telnet 21Trying .Connected to .Escape character is .220 ready, dude (vsFTPd 1.1.0: bea(促销产品 主营产品)t me, break me)/从上面的内容可以确认vsftpd 已经被启动,按Ctrl+中断会话/按q 退出telnettelnet qConnection closed. 注意:防火墙要设置一下,把FTP允许 5、vsftp相关配置文件说明 /etc/vsftpd/vsftpd.conf /etc/vsftpd.ftpusers /etc/vsftpd.user_list其中,/etc/vsftpd/vsftpd.conf 是主配置文件。/etc/vsftpd.ftpusers 中指定了哪些用户不能访问FTP服务器。/etc/vsftpd.user_list 中指定的用户默认情况( 即在/etc/vsftpd/vsftpd.con中设置了userlist_deny=YES)下也不能访问FTP 服务器,当在/etc/vsftpd/vsftpd.con中设置了userlist_deny=NO时,仅仅允许/etc/vsftpd.user_list 中指定的用户访问FTP 服务器。 让我们来看看/etc/vsftp/vsftpd.conf,用你喜欢的编辑器打开。(注意首先要把这个文件做好备份,这样来个安全第一,万一出错了还可以恢复)# Example config file /etc/vsftpd.conf# The default compiled in settings are very paranoid. This sample # file# loosens things up a bit, to make the ftp daemon more usable.# Allow anonymous FTP?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 -是否允许用户在FTP服务器文件中有写的权限#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 ftpds)local_umask=022 -设置本地用户的文件生成掩码为022# Uncomment this to allow the anonymous FTP user to upload files. # This only# has an effect if the above global write enable isactivated.# 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 -启用FTP数据的端口的连接请求# 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 -改变上传文件的所有者为root#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 formatxferlog_std_format=YES -是否使用标准的ftp xferlog日志文件格式# You may change the default value for timing out an idle session.idle_session_timeout=60 -设置空闲用户会话中断时间# 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 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格式来上传和下载#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=YESpam_service_name=vsftpd -设置pam认证服务的配置文件名称userlist_enable=YES -用户列表中的用户是否允许登入FTP#enable for standalone modelisten=YES - 使用FTP处于独立模式tcp_wrappers=YES -使用tcp_wrappers作为主机访问控制方式 默认配置:(1)允许匿名用户和本地用户登录;(2)匿名用户的登录名为ftp 或anonymous,口令为一个Email地址;(3)匿名用户不能离开匿名服务器目录/var/ftp,且只能下载不能上传;(4)本地用户的登录名为本地用户名,口令为此本地用户的口令;(5)本地用户可以离开自家目录切换至有权访问的其他目录,并在权限允许的情况下进行上传/下载;(6)写在文件/etc/vsftpd.ftpusers 中的本地用户禁止登录。在win下用ftp工具,或在浏览器也行,因为可以匿名登入,当然就可以不用密码和用户名噢,匿名登入的目录是在/var/ftp。现在因为没有什么东西,所以看到是个空目录。 默认配置当然不能满足我们需要,下面我们来进一步配置允许匿名用户上传(一个人始终是能力有限,好东西是要靠大家的,这个设置很重要噢)/修改vsftpd 的主配置文件/etc/vsftp/vsftpd.conf# vi /etc/vsftpd.conf/将如下两行前的#删除/ #anon_upload_enable=YES 允许匿名用户上传/#anon_mkdir_write_enable=YES 开启匿名用户的写和创建目录的权限/若要以上两项设置生效,同时还要求:/(1) write_enable=YES/(2) 匿名用户对文件系统的上传目录具有写权限/添加如下的配置语句/ anon_world_readable_only=NO/上面的配置语句用于放开匿名用户的浏览权限/修改后存盘退出vi/创建匿名上传目录# mkdir /var/ftp/incoming# 修改上传目录的权限# chmod o+w /var/ftp/incoming/重启动服务器#/etc/rc.d/init.d/vsftpd restart注意(1)匿名用户对/var/ftp/incoming 目录而言是其他用户,所以必须为此目录添加对其他用户的可写权限才可上传,即此目录权限的数字表示是707。(2)只有设置anon_world_readable_only=NO 后,才能开放匿名用户的读权限,即:浏览此服务器中全部的内容。 配置基本的性能和安全选项1. 设置空闲的用户会话的中断时间例如下面的配置:idle_session_timeout=600将在用户会话空闲10 分钟后被中断。2. 设置空闲的数据连接的的中断时间例如下面的配置:data_connection_timeout=120将在数据连接空闲2 分钟后被中断。3. 设置客户端空闲时的自动中断和激活连接的时间例如下面的配置:accept_timeout=60connect_timeout=60将使客户端空闲1 分钟后自动中断连接,并在中断1 分钟后自动激活连接。4. 设置最大传输速率限制例如下面的配置:local_max_rate=50000anon_max_rate=30000将使本地用户的最大传输速率为50kkbytes / sec,匿名用户的传输速率为30 kbytes / sec。5. 设置客户端连接时的端口范围例如下面的配置:pasv_min_port=50000pasv_max_port=60000将使客户端连接时的端口范围在50000 和60000 之间。这提高了系统的安全性。6. 设置chroot在默认配置中,本地用户可以切换到自家目录以外的目录进行浏览,并在权限许可的范围内进行下载和上传。这样的设置对于一个FTP 服务器来说是不安全的。如果希望用户登录后不能切换到自家目录以外的目录,则需要设置chroot 选项,涉及如下选项:chroot_local_userchroot_list_enablechroot_list_file有两种设置chroot 的方法:(1)设置所有的本地用户执行chroot只要将chroot_local_user 的值设为YES 即可,即:chroot_local_user=YES(2)设置指定的用户执行chroot需要如下的设置:chroot_local_user=NOchroot_list_enable=YESchroot_list_file= /etc/vsftpd.chroot_list这样,只有/etc/vsftpd.chroot_list 文件中指定的用户才执行chroot。 配置基于本地用户的访问控制要配置基于本地用户的访问控制,可以通过修改vsftpd 的主配置文件/etc/vsftp/vsftpd.conf 来进行,有如下两种限制方法:1. 限制指定的本地用户不能访问,而其他本地用户可访问例如下面的设置:userlist_enable=NOuserlist_deny=YESuserlist_file= /etc/vsftpd.user_list使文件/etc/vsftpd.user_list 中指定的本地用户不能访问FTP 服务器,而其他本地用户可访问FTP 服务器。2. 限制指定的本地用户可以访问,而其他本地用户不可访问例如下面的设置:userlist_enable= YESuserlist_deny= NOuserlist_file= /etc/vsftpd.user_list使文件/etc/vsftpd.user_list 中指定的本地用户可以访问FTP 服务器,而其他本地用户不可以访问FTP 服务器。 下面来个例子高安全级别匿名FTP 服务器的配置要求 仅仅允许匿名用户访问 不允许本地用户访问 关闭所有写权限 不允许匿名用户上传 设置客户端连接时的端口范围 设置 匿名用户的最大传输速率限制 设置空闲的数据连接的的中断时间 设置客户端空闲时的自动中断和激活连接的时间 配置每个主机的最大连接数 配置总的并发连接数 配置禁止访问的主机 配置安全日志# cat /etc/vsftp/vsftpd.conf# Access rightsanonymous_enable=YESlocal_enable=NOwrite_enable=NOanon_upload_enable=NOanon_mkdir_write_enable=NOanon_other_write_enable=NO# Securityanon_world_readable_only=YESconnect_from_port_20=YEShide_ids=YESpasv_min_port=50000pasv_max_port=60000# Featuresxferlog_enable=YESls_recurse_enable=NOascii_download_enable=NOasync_abor_enable=YES# Performanceone_process_model=YESidle_session_timeout=120data_connection_timeout=300accept_timeout=60connect_timeout=60anon_max_rate=50000ftpd_banner=This FTP server is anonymous only. 这里主要是限制主机访问规则# cat /etc/xinetd.d/vsftpdservice ftpdisable = nosocket_type = streamwait = nouser = rootserver = /usr/local/sbin/vsftpdper_source = 5instances = 200no_access = banner_fail = /etc/vsftpd.busy_bannerlog_on_success += PID HOST DURATIONlog_on_failure += HOST重启动服务器#/etc/rc.d/init.d/vsftpd restart完成了,现在你可以试试看是不是和上面说的限制一样了。 很多FTP服务器都要密码和用户才能下到你要的好东西,你是不是也想要过下这个隐呢?给别人一个用户名和密码,这个配置其实也很简单。虚拟用户(virtual users)的FTP 服务器的配置。虚拟用户只能访问为其提供的FTP 服务,虚拟用户不能像本地的实用户那样登录系统而访问系统的其他资源。若用户对FTP服务器站内具有写权限并且不允许访问系统的其他资源,则该用户应该使用虚拟用户才能提高系统的安全性。传统的FTP 服务器采用如下的方法实现虚拟用户:1、 在本地建立普通用户账号并设置密码2、将其登录shell 设为不可登录3、由passwd/shadow 口令系统进行认证vsftpd 的虚拟用户采用了不与系统账户口令文件合二为一的方法,也就是说,为了认证这些虚拟用户vsftpd 使用单独的口令库文件(pam_userdb),由可插拔认证模块(PAM)进行认证。使用这种方式更加安全,并且配置更灵活。 配置简单的虚拟用户FTP 服务器1、生成虚拟用户口令库文件2、配置生成vsftpd 的认证文件3、建立虚拟用户所要访问的目录并设置相应权限4、建立配置文件/生成虚拟用户口令库文件,为了建立此口令库文件,先要生成一个文本文件# cat logins.txt tom foo fred bar valid lwd dede jy !#/此文本文件的格式是:/单数行为用户名,偶数行为口令,/即:用户tom 的口令为foo;用户fred 的口令为bar/下面使用db_load 命令生成口令库文件# db_load -T -t hash -f /logins.txt /etc/vsftpd_login.db/修改口令库文件的权限# chmod 600 /etc/vsftpd_login.db/下面编辑生成虚拟用户所需的PAM 配置文件# vi /etc/pam.d/ftp

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论