RedHat6.5搭建FTP服务完整安装步骤.doc

上传人:scccc 文档编号:13592255 上传时间:2022-01-19 格式:DOC 页数:19 大小:86KB
返回 下载 相关 举报
RedHat6.5搭建FTP服务完整安装步骤.doc_第1页
第1页 / 共19页
RedHat6.5搭建FTP服务完整安装步骤.doc_第2页
第2页 / 共19页
RedHat6.5搭建FTP服务完整安装步骤.doc_第3页
第3页 / 共19页
亲,该文档总共19页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《RedHat6.5搭建FTP服务完整安装步骤.doc》由会员分享,可在线阅读,更多相关《RedHat6.5搭建FTP服务完整安装步骤.doc(19页珍藏版)》请在三一文库上搜索。

1、,基本正确,先说明,在网上找的一个 我见过的最好的vsftpd的配置,按照他的步骤安装唯一是在64位机器中的一个pam验证的路径问题导致登录不上。具体安装步骤:一. 安装:1安装Vsftpd服务相关部件:rootKce ntOS5 # yum -y in stall vsftpd*2. 确认安装PAM服务相关部件:rootKce ntOS5 # yum -y in stall pam*开发包,其实不装也没有关系,主要的目的是确认 PAM。3. 安装DB4部件包:这里要特别安装一个 db4的包,用来支持文件数据库。rootKce ntOS5 # yum -y in stall db4*二. 系统

2、帐户1. 建立Vsftpd服务的宿主用户:rootKce ntOS5 # useradd vsftpd -s /sb in/no logi n默认的Vsftpd的服务宿主用户是root ,但是这不符合安全性的需要。这里建立名字为vsftpd的用户,用他来作为支持 Vsftpd的服务宿主用户。由于该用户仅用来支持Vsftpd服务用,因此没有许可他登陆系统的必要,并设定他为不能登陆系统的用户。2建立Vsftpd虚拟宿主用户:rootKce ntOS5 no where# useradd overlord -s /sbin/no logi n本篇主要是介绍Vsftp的虚拟用户,虚拟用户并不是系统用户

3、,也就是说这些FTP的用户在系统中是不存在的。他们的总体权限其实是集中寄托在一个在系统中的某一个用户身上的所谓Vsftpd的虚拟宿主用户,就是这样一个支持着所有虚拟用户的宿主用户。由于他支撑了 FTP的所有虚拟的用户,那么他本身的权限将会影响着这些虚拟的用户,因此,处于安全性的考虑,也要非分注意对该用户的权限的控制,该用户也绝对没有登陆系统的必要,这里也设定他为不能登陆系统的用户。(这里插一句:原本在建立上面两个用户的时候,想连用户主路径也不打算给的。本来想加上 -d /home/nowhere 的,据man useradd 手册上讲述:“-d, -home HOME_DIRThe new u

4、ser will be created using HOME_DIR as the value for theuser 鈙 login directory. The default is to append the LOGIN name toBASE_DIR and use that as the login directory name. The directoryHOME_DIR does not have to exist but will not be created if it ismissi ng.使用-d参数指定用户的主目录,用户主目录并不是必须存在的。如果没有存在指定的目录的话

5、,那么它将不会被建立”。三. 调整Vsftpd的配置文件:1编辑配置文件前先备份rootKce ntOS5 # cp /etc/vsftpd/vsftpd.c onf /etc/vsftpd/vsftpd.c on f.backup2. 编辑主配置文件Vsftpd.co nfrootKce ntOS5 # vi /etc/vsftpd/vsftpd.co nf这里我将原配置文件的修改完全记录,凡是修改的地方我都会保留注释原来的配置。其中加入我对每条配置项的认识,对于一些比较关键的配置项这里我做了我的观点,并且原本英语的说明我也不删除,供参考对比用。# Allow anonym ous FTP?

6、 (Beware - allowed by default if you comme nt this out).#anonymo us_e nable=YESanonymo us_e nable=NO设定不允许匿名访问# Un comme nt this to allow local users to log in.local_e nable=YES设定本地用户可以访问。注意:主要是为虚拟宿主用户,如果该项目设定为 NO那么所有 虚拟用户将无法访问。# Un comme nt this to en able any form of FTP write comma nd.write_e nabl

7、e=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 ftpds) local_umask=022设定上传后文件的权限掩码。# Uncomment this to allow the anonymous FTP user to upload files. This only# has an effect if the above global write ena

8、ble is activated. Also, you will# obviously n eed to create a directory writable by the FTP user.#anon _upload_e nable=YESanon _upload_e nable=NO禁止匿名用户上传。# Un comme nt this if you want the anonym ous FTP user to be able to create# new directories.#anon_ mkdir_write_e nable=YESanon_ mkdir_write_e nab

9、le=NO禁止匿名用户建立目录。# Activate directory messages - messages give n to remote users whe n they# go into a certain directory.dirmessage_e nable=YES设定开启目录标语功能。# Activate loggi ng of uploads/dow nl oads.xferlog_e nable=YES设定开启日志记录功能。# Make sure PORT tran sfer connections origi nate from port 20 (ftp-data).

10、 conn ect_from_port_20=YES设定端口 20进行数据连接。# If you want, you can arrange for uploaded anonym ous files to be owned by# a different user. Note! Using root for uploaded files is not# recomme nded!#chow n_ uploads=YESchow n_uploads=NO设定禁止上传文件更改宿主。#chow n_user name=whoever# You may override where the log

11、file goes if you like. The default is show n# below.xferlog_file=/var/log/vsftpd.log设定Vsftpd的服务日志保存路径。注意,该文件默认不存在。必须要手动touch出来,并 且由于这里更改了 Vsftpd的服务宿主用户为手动建立的Vsftpd。必须注意给与该用户对日志的写入权限,否则服务将启动失败。# If you want, you can have your log file in sta ndard ftpd xferlog format xferlog_std_format=YES设定日志使用标准的记录

12、格式。# You may cha nge the default value for tim ing out an idle sessi on.#idle_sessi on _timeout=600设定空闲连接超时时间,这里使用默认。将具体数值留给每个具体用户具体指定,当然如果不指定的话,还是使用这里的默认值600,单位秒。# You may cha nge the default value for tim ing out a data conn ecti on.#data_c onn ecti on _timeout=120设定单次最大连续传输时间,这里使用默认。将具体数值留给每个具体用户

13、具体指定,当然如果不指定的话,还是使用这里的默认值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.#n opriv_user=ftpsecureno priv_user=vsftpd设定支撑Vsftpd服务的宿主用户为手动建立的Vsftpd用户。注意,一旦做出更改宿主用户后,必须注意一起与该服务相关的读写文件的读写赋权问题。比如日志文件就必须给与该用户

14、写入权限等。# En able this and the server will recog nise asynchronous ABOR requests. Not# recommended for security (the code is non-trivial). Not enabling it,# however, may con fuse older FTP clie nts.asyn c_abor_e nable=YES设定支持异步传输功能。# By default the server will pretend to allow ASCII mode but in fact i

15、gnore# the request. Turn on the below options to have the server actually do ASCII# man gli ng on files whe n in ASCII mode.# Beware that on some FTP servers, ASCII support allows a denial of service# attack (DoS) via the comma nd SIZE /big/file in ASCII mode. vsftpd# predicted this attack and has a

16、lways bee n safe, report ing the size of the# raw file.# ASCII mangling is a horrible feature of the protocol.ascii_upload_e nable=YESascii_dow nl oad_e nable=YES设定支持ASCII模式的上传和下载功能。# You may fully customise the logi n banner stri ng:ftpd_ba nn er=This Vsftp server supports virtual users A_A设定Vsftpd

17、的登陆标语。# You may specify a file of disallowed anonym ous e-mail addresses. Appare ntly# useful for combatt ing certa in DoS attacks.#de ny_email_e nable=YES# (default follows)#ba nn ed_email_file=/etc/vsftpd/ba nn ed_emails# You may specify an explicit list of local users to chroot() to their home# d

18、irectory. If chroot_local_user is YES, then this list becomes a list of# users to NOT chroot().#chroot_list_e nable=YESchroot_list_e nable=NO禁止用户登出自己的FTP主目录。# (default follows)#chroot_list_file=/etc/vsftpd/chroot_list# You may activate the -R optio n to the built in Is. This is disabled by# default

19、to avoid remote users being able to cause excessive I/O on large# sites. However, some broke n FTP clie nts such as n cftp and mirror assume# the presenee of the -R option, so there is a strong case for enabling it.#ls_recurse_e nable=YESls_recurse_e nable=NO禁止用户登陆FTP后使用ls -R的命令。该命令会对服务器性能造成巨大开销。如果该

20、项被允许,那么挡多用户同时使用该命令时将会对该服务器造成威胁。# When liste n directive is en abled, vsftpd runs in sta ndal one mode and# liste ns on IPv4 sockets. This directive cannot be used in conj unction# with the liste npv6 directive.liste n=YES设定该Vsftpd服务工作在StandAlone模式下。顺便展开说明一下,所谓StandAlone模式 就是该服务拥有自己的守护进程支持,在ps -A命令下我

21、们将可用看到vsftpd的守护进程名。如果不想工作在 StandAlone模式下,则可以选择SuperDaemon模式,在该模式下| vsftpd将没有自己的守护进程,而是由超级守护进程Xinetd全权代理,与此同时,Vsftp服务的许多功能将得不到实现。# This directive en ables liste ning on IPv6 sockets. To liste n on IPv4 and IPv6# sockets, you must run two copies of vsftpd whith two con figurati on files.# Make sure, t

22、hat one of the liste n optio ns is comme nted !#listen_ipv6=YESpam_service_ name=vsftpd设定PAM服务下Vsftpd的验证配置文件名。因此,PAM验证将参考/etc/pam.d/下的vsftpd文件配置。userlist_e nable=YES设定userlist_file中的用户将不得使用 FTP。tcp_wrappers=YES设定支持 TCP Wrappers。#KC: The following entries are added for supporting virtual ftp users.以下

23、这些是关于 Vsftpd虚拟用户支持的重要配置项目。默认Vsftpd.conf中不包含这些设定项目,需要自己手动添加配置。guest_e nable=YES设定启用虚拟用户功能。guest_user name=overlord指定虚拟用户的宿主用户。virtual_use_local_privs=YES设定虚拟用户的权限符合他们的宿主用户。user_c on fig_dir=/etc/vsftpd/vc onf设定虚拟用户个人 Vsftp的配置文件存放路径。也就是说,这个被指定的目录里,将存放每个Vsftp虚拟用户个性的配置文件,一个需要注意的地方就是这些配置文件名必须和虚拟用户名相同。保存退

24、出。3. 建立Vsftpd的日志文件,并更该属主为 Vsftpd的服务宿主用户rootKce ntOS5 # touch /var/log/vsftpd.logrootKce ntOS5 # chow n vsftpd.vsftpd /var/log/vsftpd.log4. 建立虚拟用户配置文件存放路径:rootKce ntOS5 # mkdir/etc/vsftpd/vc onf/三. 制作虚拟用户数据库文件1. 先建立虚拟用户名单文件:rootKce ntOS5 # touch /etc/vsftpd/virtusers建立了一个虚拟用户名单文件 ,这个文件就是来记录 vsftpd虚拟用

25、户的用户名和口令的数 据文件,我这里给它命名为 virtusers。为了避免文件的混乱,我把这个名单文件就放置在/etc/vsftpd/ 下。2. 编辑虚拟用户名单文件:rootKce ntOS5 # vi /etc/vsftpd/virtusers myFtpUser #改成自己的用户名123456n ear123456nearmello123456mello编辑这个虚拟用户名单文件,在其中加入用户的用户名和口令信息。格式很简单:一行用户名,一行口令”。3. 生成虚拟用户数据文件:rootKce ntOS5 # db_load -T -t hash -f /etc/vsftpd/virtus

26、ers /etc/vsftpd/virtusers.db#这个命令不是一次性的,每次添加修改用户后都需要执行这个命令。4. 察看生成的虚拟用户数据文件rootKce ntOS5 # ll /etc/vsftpd/virtusers.db-rw-r-r- 1 root root 12288 Sep 16 03:51 /etc/vsftpd/virtusers.db需要特别注意的是,以后再要添加虚拟用户的时候,只需要按照一行用户名,一行口令”的格式将新用户名和口令添加进虚拟用户名单文件。但是光这样做还不够,不会生效的哦!还要再执行一遍“ db_load -T -t hash -f虚拟用户名单文件虚

27、拟用户数据库文件.db”的命令使其生效才可以!四. 设定PAM验证文件,并指定虚拟用户数据库文件进行读取1. 察看原来的Vsftp的PAM验证配置文件:rootKce ntOS5 # cat /etc/pam.d/vsftpd#%PAM-1.0sessi on opti onal pam_key in it.so force revokeauth required pam_listfile.so item=user sen se=de ny file=/etc/vsftpd/ftpuserson err=succeedauth required pam_shells.soauth in clu

28、de password-auth #这里与原来网上的不同acco unt in clude password-auth #这里与原来网上的不同sessi on required pam_logi nu id.sosessi on in elude password-auth #这里与原来网上的不同2在编辑前做好备份:rootKce ntOS5 # cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.backup3.编辑Vsftpd的PAM验证配置文件rootKce ntOS5 # vi /etc/pam.d/vsftpd#%PAM-1.0/lib/security/p

29、am_userdb.so/lib/security/pam_userdb.sodb=/etc/vsftpd/virtusersdb=/etc/vsftpd/virtusersauthsufficie ntacco unt sufficie nt sessi on opti onal pam_key in it.so force revoke auth required pam_listfile.so item=user sen se=de ny file=/etc/vsftpd/ftpusers on err=succeed auth required pam_shells.soauth in

30、 clude password-auth #可能与以前网上的资料不同acco unt in clude password-auth #可能与以前网上的资料不同sessi on required pam_logi nu id.sosessi on in clude password-auth #可能与以前网上的资料不同#注意:此步骤的黑体文件部分,如果按照上面这么写,会出现登录时无法登录,查看/var/log/secure 日志的时候,发现 localhost vsftpd29417: PAM un able to dlope n(/lib/security/pam_userdb.so):/li

31、b/security/pam_userdb.so: cannot ope n shared object file: No such file or directory原因是64位的操作系统中/lib/security 并没有pam_userdb.so因此,出现这种情况后,将/lib/security/ 去掉,不写目录。即:auth sufficie ntpam_userdb.so db=/etc/vsftpd/virtusersacco unt sufficie nt pam_userdb.sodb=/etc/vsftpd/virtusers五. 虚拟用户的配置1. 规划好虚拟用户的主路径:

32、rootKce ntOS5 # mkdir /opt/vsftp/2. 建立测试用户的FTP用户目录:rootKce ntOS5 # mkdir /opt/vsftp/myFtpUser/3. 建立虚拟用户配置文件模版:rootKcentOS5 # /etc/vsftpd/vc onf/vcon f.tmp4. 定制虚拟用户模版配置文件:rootKce ntOS5 # vi /etc/vsftpd/vco nf/vcon f.tmplocal_root=/opt/v sftp/virtuser # 得自己添加指定虚拟用户的具体主路径。anonymo us_e nable=NO设定不允许匿名用户

33、访问。write_e nable=YES设定允许写操作。local_umask=022设定上传文件权限掩码。anon _upload_e nable=NO设定不允许匿名用户上传 。anon_ mkdir_write_e nable=NO设定不允许匿名用户建立目录。idle_sessi on _timeout=600设定空闲连接超时时间。data_c onnection _timeout=120设定单次连续传输最大时间。max_clie nts=1O设定并发客户端访问个数 。max_per_ip=5设定单个客户端的最大线程数,这个配置主要来照顾Flashget、迅雷等多线程下载软件local_m

34、ax_rate=50000设定该用户的最大传输速率,单位b/s。这里将原vsftpd.conf配置文件经过简化后保存作为虚拟用户配置文件的模版。这里将并不需要指定太多的配置内容,主要的框架和限制交由 Vsftpd的主配置文件vsftpd.conf来定义,即虚拟用户配置文件当中没有提到的配置项目将参考主配置文件中的设定。而在这里作为虚拟用户的配置文件模版只需要留一些和用户流量控制,访问方式控制的配置项目就可以了。这里的关键项是local_root这个配置,用来指定这个虚拟用户的FTP主路径。5更改虚拟用户的主目录的属主为虚拟宿主用户:rootKce ntOS5 # chow n -R overl

35、ord.overlord /opt/vsftp/新加用户后重做6.检查权限:rootKce ntOS5 # ll /opt/vsftp/ |total 4drwxr-xr-x 2 overlord overlord 4096 Sep 16 05:14 myFtpUser六. 给测试用户定制:1. 从虚拟用户模版配置文件复制:rootKce ntOS5 # cp /etc/vsftpd/vc onf/vcon f.tmp /etc/vsftpd/vc on f/myFtpUs2. 针对具体用户进行定制:rootKce ntOS5 # vi /etc/vsftpd/vco nf/myFtpUser

36、 local_root=/opt/vsftp/myFtpUser anonymo us_e nable=NO write_e nable=YES local_umask=022 anon _upload_e nable=NO anon_ mkdir_write_e nable=NOidle_sessi on _timeout=300 data_c onnection _timeout=90 max_clie nts=1 max_per_ip=1 local_max_rate=25000 rootKce ntOS5 # service vsftpd startOK Start ing vsftp

37、d for vsftpd:八:测试rootKce ntOS5 # ftp补充:500 OOPS:错误种可能是命令的原因:有可能是你的vsftpd.con配置文件中有不能被实别的命令:YES或NO 后面有空格。我遇到的是命令后面有空格。因为我是用GEDIT来编辑的配置文件500 OOPSvsftpd userXXXXXXX ” gran ted access原因:/etc/vsftpd/vsftp.conf中guest_enable=YES 没有写,导致用户登录不上 。妈蛋的,就这个破原因,我找了一天。550权限错误,不能创建目录和文件500 OOPS: cannot change direct

38、ory:/home/xxxx错误解决方案。解决方法:关闭selinux# vi /etc/seli nux/config将 SELINUX=XXX -XXX代表级别改为SELINUX=disabled重启我再使用vsftpd的时候,一开始发现上传的文件都是/opt/vsftpd/shopSystemFtp 目录中,所以,修改 /etc/vsftpd/vconf/shopSystemFtp配置文件,设置 local_root 为/var/www/petShopFtpFile/shoplmg 但是,当改为数的local_root的时候,发现无法上传 到这个目录里,而是上传到了overlord目录中,搞了半天,发现是目录所有者的问题,不能直接在二级以上的目录设置,因此我把petShopFtpFile目录移动到/var/下,然后把petShopFtpFile目录的所有者设置为 overlord.搞定了 。chown -R overlord.overlord /var/petShopFtpFile/执行这个命令。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1