通过之前的几篇文章,我们都知道了如何配置PHP环境,也知道如何保护我们的vps以及如何绑定多个域名建设多个网站。有时候我们为了让我们的朋友也能用我们的vps建站又不想给他们太多权限,有时候我们想要当个主机商卖卖虚拟空间过过瘾又不想装管理环境,那么就想要装个ftp服务器了。

经过前面的教程,相信大家对管理vps的操作是比较熟悉了,这里我就不在截图了,安装ftp服务器也是比较简单的,相信大家可以轻松学会。

一安装环境

1.先检查有没有安装   rpm -q vsftpd
如果没有安装   yum install vsftpd

2.先关闭防火墙进行调试.

service iptables stop

或者一步到位   添加规则允许21端口通行
vi /etc/sysconfig/iptables

添加一条 
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT

为了让FLASHFXP之类的软件更好的连接服务器,得让VSFTPD支持被动模式才行:

b.防火墙配置开放:

-A INPUT -p tcp --dport 30000:30100 -j ACCEPT
重启防火墙即可
service iptables restart

这时应该可以用 winscp进行 SFTP连接了  ROOT帐户
现在开始设置FTP   默认的已经可以用匿名登录了

二。备份 etc/vsftpd/vsftpd.conf
cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak

编辑vsftpd.config文件   vi /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
设定不允许匿名用户访问。

为了让FLASHFXP之类的软件更好的连接服务器,得让VSFTPD支持被动模式才行,上面已经开通相应端口防火墙,在最后加入
pasv_enable=YES
pasv_max_port=30100
pasv_min_port=30000
(上面的30000--30100端口号可以是其它的,在此举例)

/usr/sbin/setenforce 0 立刻关闭 SELINUX

#mkdir /tmp/test   //首先创建好目录

#adduser -d /tmp/test -g ftp -s /sbin/nologin test

//-s /sbin/nologin是让其不能登陆系统,-d 是指定用户目录为/tmp/test ,即该账户只能登陆ftp,却不能用做登陆系统用。-g 是指定为FTP用户组

#passwd test

Changing password for user beinan.//接下来会出现让你设置新的密码

**************************************************
【如果要删除用户,用下面代码:
userdel test      //userdel + 用户 即可删除ftp用户】
***********************************************************

有必要的话  设置TEST目录权限

修改/var/www目录属性:
$ chmod -R 777 /var/www 递归地给此目录下所有文件和子目录的读、写、执行权限
$ chgrp -R ftp   /var/www 递归地把此目录及该目录下所有文件和子目录的组属性设置成ftp组

三。接着 限制用户目录,不得改变目录到上级

修改/etc/vsftpd/vsftpd.conf
将这两行
#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd.chroot_list
注释去掉
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list

新增一个文件: /etc/vsftpd/chroot_list
内容写需要限制的用户名:
test

重新启动vsftpd

# service vsftpd restart

四。最后为了防止服务器由于断电、重启等现象发生,导致ftp进程在开机后未启动,将其添加到开机启动文件中:

(1)找到/etc/rc.local文件

(2)打开该文件,在最后一行添加:service vsftpd start

(3)保存,退出

附:vsftpd的配置文件说明:
vsftpd.ftpusers:位于/etc目录下。它指定了哪些用户账户不能访问FTP服务器,例如root等。
vsftpd.user_list:位于/etc目录下。该文件里的用户账户在默认情况下也不能访问FTP服务器,仅当vsftpd .conf配置文件里启用userlist_enable=NO选项时才允许访问。
vsftpd.conf:位于/etc/vsftpd目录下。来自定义用户登录控制、用户权限控制、超时设置、服务器功能选项、服务器性能选项、服务器响应消息等FTP服务器的配置。
(1)用户登录控制
anonymous_enable=YES,允许匿名用户登录。
no_anon_password=YES,匿名用户登录时不需要输入密码。
local_enable=YES,允许本地用户登录。
deny_email_enable=YES,可以创建一个文件保存某些匿名电子邮件的黑名单,以防止这些人使用Dos攻击。
    banned_email_file=/etc/vsftpd.banned_emails,当启用deny_email_enable功能时,所需的电子邮件黑名单保存路径(默认为/etc/vsftpd.banned_emails)。
(2)用户权限控制
write_enable=YES,开启全局上传权限。
local_umask=022,本地用户的上传文件的umask设为022(系统默认是077,一般都可以改为022)。
anon_upload_enable=YES,允许匿名用户具有上传权限,很明显,必须启用write_enable=YES,才可以使用此项。同时我们还必须建立一个允许ftp用户可以读写的目录(前面说过,ftp是匿名用户的映射用户账号)。
anon_mkdir_write_enable=YES,允许匿名用户有创建目录的权利。
chown_uploads=YES,启用此项,匿名上传文件的属主用户将改为别的用户账户,注意,这里建议不要指定root账号为匿名上传文件的属主用户!
chown_username=whoever,当启用chown_uploads=YES时,所指定的属主用户账号,此处的whoever自然要用合适的用户账号来代替。
chroot_list_enable=YES,可以用一个列表限定哪些本地用户只能在自己目录下活动,如果chroot_local_user=YES,那么这个列表里指定的用户是不受限制的。
     chroot_list_file=/etc/vsftpd.chroot_list,如果chroot_local_user=YES,则指定该列表(chroot_local_user)的保存路径(默认是/etc/vsftpd.chroot_list)。
nopriv_user=ftpsecure,指定一个安全用户账号,让FTP服务器用作完全隔离和没有特权的独立用户。这是vsftpd系统推荐选项。
async_abor_enable=YES,强烈建议不要启用该选项,否则将可能导致出错!
ascii_upload_enable=YES;ascii_download_enable=YES,默认情况下服务器会假装接受ASCⅡ模式请求但实际上是忽略这样的请求,启用上述的两个选项可以让服务器真正实现ASCⅡ模式的传输。
注意:启用ascii_download_enable选项会让恶意远程用户们在ASCⅡ模式下用“SIZE/big/file”这样的指令大量消耗FTP服务器的I/O资源。
这些ASCⅡ模式的设置选项分成上传和下载两个,这样我们就可以允许ASCⅡ模式的上传(可以防止上传脚本等恶意文件而导致崩溃),而不会遭受拒绝服务攻击的危险。
(3)用户连接和超时选项
idle_session_timeout=600,可以设定默认的空闲超时时间,用户超过这段时间不动作将被服务器踢出。
data_connection_timeout=120,设定默认的数据连接超时时间。
(4)服务器日志和欢迎信息
dirmessage_enable=YES,允许为目录配置显示信息,显示每个目录下面的message_file文件的内容。
ftpd_banner=Welcome to blah FTP service,可以自定义FTP用户登录到服务器所看到的欢迎信息。
xferlog_enable=YES,启用记录上传/下载活动日志功能。
xferlog_file=/var/log/vsftpd.log,可以自定义日志文件的保存路径和文件名,默认是/var/log/vsftpd.log。
anonymous_enable=YES 允许匿名登录local_enable=YES 允许本地用户登录
write_enable=YES 开放本地用户写权限
local_umask=022 设置本地用户生成文件的掩码为022
#anon_upload_enable=YES 此项设置允许匿名用户上传文件
#anon_mkdir_write_enable=YES 开启匿名用户的写和创建目录的权限
dirmessage_enable=YES 当切换到目录时,显示该目录下的.message隐藏文件的内容
xferlog_enable=YES 激活上传和下载日志
connect_from_port_20=YES 启用FTP数据端口的连接请求
#chown_uploads=YES 是否具有上传权限. 用户由chown_username参数指定。
#chown_username=whoever 指定拥有上传文件权限的用户。此参数与chown_uploads联用。
#xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES 使用标准的ftpd xferlog日志格式
#idle_session_timeout=600 此设置将在用户会话空闲10分钟后被中断
#data_connection_timeout=120 将在数据连接空闲2分钟后被中断
#ascii_upload_enable=YES 启用上传的ASCII传输方式
#ascii_download_enable=YES 启用下载的ASCII传输方式
#ftpd_banner=Welcome to blah FTP service 设置用户连接服务器后显示消息
#deny_email_enable=NO 此参数默认值为NO。当值为YES时,拒绝使用banned_email_file参数指定文件中所列出的e-mail地址用户登录。
#banned_email_file=/etc/vsftpd.banned_emails 指定包含拒绝的e-mail地址的文件.
#chroot_list_enable=YES 设置本地用户登录后不能切换到自家目录以外的别的目录
#chroot_list_file=/etc/vsftpd.chroot_list
#ls_recurse_enable=YES
pam_service_name=vsftpd 设置PAM认证服务的配置文件名称,该文件存放在/etc/pam.d/
userlist_enable=YES 此项配置/etc/vsftpd.user_list中指定的用户也不能访问服务器,若添加userlist_deny=No,则仅仅/etc/vsftpd.user_list文件中的用户可以访问,其他用户都不可以访问服务器。如过userlist_enable=NO,userlist_deny=YES,则指定使文件/etc/vsftpd.user_list中指定的用户不可以访问服务器,其他本地用户可以访问服务器。
listen=YES 指明VSFTPD以独立运行方式启动
tcp_wrappers=YES 在VSFTPD中使用TCP_Wrappers远程访问控制机制,默认值为YES

#***********************************************************************
#附 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? (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
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
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
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
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
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd whith two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

#######################################################################

来源:138vps推荐网

vps建站教程 CentOS6如何安装配置FTP服务器的更多相关文章

  1. ()centos6.8安装配置ftp服务器

    ftp传输原理 客户端通过某软件用某个端口(a端口)向服务端发起tcp连接请求,同时告诉服务端客户端另一个空闲端口号(b端口),服务端用21端口与客户端建立一条控制连接通道. 接着在默认情况下,服务端 ...

  2. Vultr VPS建站攻略 – 一键安装LNMP无面板高性能WEB环境

    在"Vultr VPS建站攻略 - 一键安装宝塔面板架设LNMP/LAMP Web环境"文章中,VULTR中文网分享到我们常用的可视化面板宝塔面板安装在VULTR VPS主机中建站 ...

  3. centos6.4安装配置vpn服务器步骤详解

      centos6.4安装配置vpn服务器步骤详解,从安装VPN到配置VPN服务器.配置VPN服务器的路由转发功能,每一步都很详细   一.VPN服务器环境说明 操作系统:CentOS release ...

  4. Vultr VPS建站攻略 – 一键安装宝塔面板架设LNMP/LAMP Web环境

    我们选择VULTR VPS建站的还是比较多的,其主要原因在于商家的稳定,毕竟我们用来建站选择服务器价格考虑的不是主要的(当然VULTR价格也是比较便宜),最为主要的是因为VULTR商家比较稳定,而且多 ...

  5. win7下安装配置ftp服务器

    1. win7操作系统自带了ftp组件,所以不需要另外下载.只需要在控制面板中,添加或删除组件中启用即可. 2. 在管理上,ftp和iis是属于同一个目录的.ftp也可以算是internet info ...

  6. CentOS8.0-1905安装配置ftp服务器

    关键词:CentOS8/RHEL8;安装配置FTP/安装配置VSFTPD;被动模式/PASV##CentOS8.0-1905发布后,尝试将FTP服务器迁移至新版本的CentOS中,但是测试过程中,在防 ...

  7. Discuz建站教程:本地安装discuz网站

    网站建目前都很简单,建站容易,管理难,网站做大优化更难.本人有建站经验,目前给大家分享一下如何建站,当然,目前使用的是本地建站,因为非本地建站需要购买域名和网站空间,当然,朋友们想真正建站的,对于一些 ...

  8. CentOS 7安装配置FTP服务器

    CentOS 7下FTP服务器的安装配置. 假设我们有以下要求 路径 权限 备注 /ftp/open 公司所有人员包括来宾均可以访问 只读 /ftp/private 仅允许Alice.Jack.Tom ...

  9. 安装配置ftp服务器

    1.安装ftp服务 检查是否安装vsftpd rpm -qa|grep vsftpd 安装 vsftpd yum -y install vsftpd 2.配置 编辑 文件 /etc/vsftpd/vs ...

随机推荐

  1. php伪静态配置

    配置虚拟主机和伪静态 1.开启Apache的rewrite模块 LoadModule rewrite_module modules/mod_rewrite.so 2.开启虚拟主机功能 # Virtua ...

  2. DNS原理及解析过程

    本文主要参考自:http://369369.blog.51cto.com/319630/812889 并做了小幅修改 什么是DNS? 因特网上的主机和人类一样,也可以使用多种方式进行识别.主机的一种识 ...

  3. React.js学习笔记(一):组件协同与mixin

    组件协同: <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF ...

  4. bzoj2429- 聪明的猴子

    题意其实就是说有很多个点,求一组边把它们都连接起来,并且最大的那条边最小.很明显这就是一个最小生成树,是一颗保证最长边最短的树. 代码 刚刚学了个Borůvka算法,于是写了两个. Borůvka # ...

  5. CodeChef KnightMov

    码死了...考试的时候基本上是写一会儿思考一会儿人生....考完了调了调...最后400行+....不应该这么长的....以后重写一下再补题解..... 也许这就是蒟蒻吧.jpg 安利cstdio博客 ...

  6. Django 2.0 学习(14):Django ORM 数据库操作(上)

    Django ORM 数据库操作(上) ORM介绍 映射关系: 数据库表名 ---------->类名:数据库字段 ---------->类属性:数据库表一行数据 ----------&g ...

  7. Day21-获取用户请求相关信息及请求头

    1. request里面还包含请求头等信息,可以打印看一下. views.py中的程序 from django.shortcuts import render,HttpResponse from dj ...

  8. [HNOI2007]分裂游戏 博弈论

    题面 题面 题解 这题的思路比较特别,观察到我们的每次操作实质上是对于一颗豆子的操作,而不是对一瓶豆子的操作,因此我们要把每颗豆子当做一个独立的游戏,而它所在的瓶子代表了它的SG值. 瓶子数量很少,因 ...

  9. 学习笔记:使用opencv做双目测距(相机标定+立体匹配+测距).

    最近在做双目测距,觉得有必要记录点东西,所以我的第一篇博客就这么诞生啦~ 双目测距属于立体视觉这一块,我觉得应该有很多人踩过这个坑了,但网上的资料依旧是云里雾里的,要么是理论讲一大堆,最后发现还不知道 ...

  10. Redis安装部署【转】

    Redis是一种高级key-value数据库.它跟memcached类似,不过数据可以持久化,而且支持的数据类型很丰富.有字符串,链表,集 合和有序集合.支持在服务器端计算集合的并,交和补集(diff ...