CentOS7搭建ftp服务器(vsftpd,亲测成功)

安装vsftpd
sudo yum install vsftpd
 
配置参数
命令行输入

vim /etc/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.
#
#
# Run standalone?  vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
listen_ipv6=YES
#
# Allow anonymous FTP? (Disabled by default).
anonymous_enable=NO
#
# 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
#
# If enabled, vsftpd will display directory listings with the time
# in  your  local  time  zone.  The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=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.
# Note that the default log file location is /var/log/xferlog in this case.
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 restrict local users to their home directories.  See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# 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().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES
chroot_list_enable=YES
user_sub_token=$USER
local_root=/home/$USER/ftp
# (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
#
# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=ftp
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO

#
# Uncomment this to indicate that vsftpd use a utf8 filesystem.
utf8_filesystem=YES

配置说明
anonymous_enable=NO 拒绝匿名登陆

write_enable=YES 设置可以上传文件,这个设置看需要个人需要

xferlog_enable=YES 开启日志记录

xferlog_file=/var/log/vsftpd.log 设置日志文件路径

xferlog_std_format=YES 设置日志格式为标准输出

connect_from_port_20=YES 绑定20端口

ftpd_banner=Welcome to FTP service. 欢迎语句,在使用shell时可以看到

chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd.chroot_list
上面的这几个配置实现的功能是:用户被限制在自己的主目录下。用户名单来源于/etc/vsftpd.chroot_list

user_sub_token=$USER

local_root=/home/$USER/ftp
添加一个user_sub_token ,以便插入用户名在我们local_root directory路径,以便我们的配置将为该用户,并可能被添加任何未来的用户

pam_service_name=ftp原配置中为vsftpd,ubuntu用户需要更改成ftp

如果登录后出现如下错误,则在/etc/vsftpd.conf文件内添加allow_writeable_chroot=YES

500 OOPS: vsftpd: refusing to run with writable root inside chroot ()
 
创建ftp用户
mkdir /home/ftpuser
sudo useradd ftpuser -d /home/ftpuser -m
sudo passwd ftpuser
mkdir /home/ftpuser/ftp
chmod 777 -R /home/username/ftp
usermod -s /sbin/nologin ftpuser


/etc/vsftpd.chroot_list要自己创建,并将ftpuser放进去

启动vsftpd或者重启
systemctl start vsftpd 或 service vsftpd start
systemctl restart vsftpd 或 service vsftpd restart
登陆
使用filezilla或者打开文件管理器输入ftp://ipaddress

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/548035.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

handler类型的定时器

2019独角兽企业重金招聘Python工程师标准>>> 一、采用Handle与线程的sleep(long)方法 Handler主要用来处理接受到的消息。这只是最主要的方法,当然Handler里还有其他的方法供实现,有兴趣的可以去查API,这里不过多解释。 1. 定义…

Vue路由基本操作

路由index.js import Vue from vue import VueRouter from vue-router import Home from ../views/Home.vue import Me from ../views/me.vue import About from "../views/About.vue" import Centor from "/views/Center.vue" import _404 from "..…

Windows 10 搭建Python3 安装使用 protobuf

Windows 10 搭建Python3 安装使用 protobuf Protobuf对比XML、Json等其他序列化的优势 protobuf 不管是处理时间上,还是空间占用上都优于现有的其他序列化方式。内存暂用是java 序列化的1/9,时间也是差了一个数量级,一次操作在1us左右。缺点…

如何用PS的样式制作图片椭圆形边框

制作过程: 1)点击文件→新建,画布尺寸按需,背景白色。 2)点击形状工具→椭圆形工具,画一椭圆,位置居中大小按需。 3)选择样式,本例如图1 4)点击选框工具→椭圆…

Vue + SpringBoot跨域

Vue设置 1、在项目根目录创建文件vue.config.js module.exports {devServer: {proxy: {/api: {target: http://zlf.plus, //对应自己的接口changeOrigin: true,ws: true,pathRewrite: {^/api: }}}}}2、 在main.js中配置 import Vue from vue import App from ./App.vue imp…

Windows10 64位 安装 Postgresql 数据库

Windows10 64位 安装 Postgresql 数据库 1,下载Postgresql 10.7 版本,下载地址 https://www.enterprisedb.com/downloads/postgres-postgresql-downloads 2,打开安装包,傻瓜式默认安装,请谨记 “数据库密码” 和 “…

node.js入门小案例

nodejs 和 Java node.js是运行在服务端的JavaScript。node.js是一个基于chrome JavaScript 运行时建立的一个平台。底层架构 是JavaScript。 node.js是一个事件驱动I/O服务端JavaScript环境,chrome V8引擎执行JavaScript的速度非常快,性能非常好。 可以…

Windows10 64位安装DB2数据库

Windows10 64位安装DB2数据库 安装前准备 : 系统:Windows10 64位 DB2 v9.5下载地址(迅雷):http://big3.ddooo.com/db2_93661.rar 选择安装包解压位置,并复制记住: 去到解压的安装目录&#xff…

crossdomain.xml

使用crossdomain.xml让Flash可以跨域传输数据 本文来自http://www.mzwu.com/article.asp?id975 一、概述 位于www.mzwu.com域中的SWF文件要访问www.163.com的文件时,SWF首先会检查163服务器目录下是否有crossdomain.xml文件,如果没有,则访问…

npm包管理器安装模块

使用npm init 初始化目录(npm init -y) 可以省略中间过程 会在项目根目录生成一个文件 package.json(类似于Maven 的pom文件) {"name": "test","version": "1.0.1","description": "第一次创建…

Git报错: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

Git报错: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 在使用Git来克隆仓库报了错误,如下: fatal: unable to access ‘https://github.com/xiaobingchan/machine_learn/‘: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in co…

linux下的redis配置;

2019独角兽企业重金招聘Python工程师标准>>> linux环境下的php和redis的集成:http://blog.csdn.net/21aspnet/article/details/6960757 转载于:https://my.oschina.net/wangfree/blog/115987

Babel入门

Babel简介 Babel 是一个工具链,主要用于将 ECMAScript 2015 版本的代码转换为向后兼容的 JavaScript 语法,以便能够运行在当前和旧版本的浏览器或其他环境中。 中文文档 安装 npm install -g bable-cli 全局安装 babel --version 查看版本 Babel的…

Server 2012使用Windows PowerShell cmdlet安装角色和角色服务功能

Server 2012使用Windows PowerShell cmdlet安装角色和角色服务功能 Server 2012使用Windows PowerShell cmdlet安装角色和角色服务功能 Windows Server 2012 安装 SQL server 2008 出现了如下错误:解决方案1(简单,界面操作)&…

commonjs 和 es6模块化开发入门

commonjs模块化 首先写一个api,提供给外部调用 //commonjslet sum (a,b)> ab;// 暴露接口 module.exports {sum // sum:sum }导入调用 const m require(./Api.js)console.log(m.sum(10,20));es6模块化 首先写一个api,提供给外部调用 //es6 exp…

黑马程序员_7k面试题交通管理系统

------- android培训、java培训、期待与您交流! ---------- //以下知识来在张孝祥老师的讲解总结 项目需求 模仿实现十字路口的交通灯系统逻辑,具体需求如下 1.异步随机生成按照各个线路行驶的车辆 例如: 由南而来去往北向的车辆......直行车…

python新建txt文件,并逐行写入数据

python2新建txt文件,并逐行写入数据 #codingutf-8 import os txtName "codingWord.txt" ffile(txtName, "a") for i in range(1,100):if i % 2 0:new_context "C" \nf.write(new_context)else:new_context "Python" …

轻松获取LAMP,LNMP环境编译参数配置

轻松获取LAMP,LNMP环境编译参数配置[转载] 大家是否遇到过去了新公司,公司内的LAMP,LNMP等所有的环境都是配置好的(已经在提供服务了),公司又没有留下部署文档,甚至安装LAMP,LAMP等环…

eclipse搭建maven开发环境

eclipse搭建maven开发环境 eclipse搭建maven开发环境 maven作为一个项目构建工具,在开发的过程中很受欢迎,可以帮助管理项目中的bao依赖问题,另外它的很多功能都极大的减少了开发的难度,下面来介绍maven的安装及与eclipse的集成。…