摘要

vsftpd 是“very secure FTP daemon”的缩写,安全性是它的一个最大的特点。vsftpd 是一个 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux、BSD、Solaris、 HP-UNIX等系统上面,是一个完全免费的、开放源代码的ftp服务器软件,支持很多其他的 FTP 服务器所不支持的特征。比如:非常高的安全性需求、带宽限制、良好的可伸缩性、可创建虚拟用户、支持IPv6、速率高等。

vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序。特点是小巧轻快,安全易用。(来自百度百科)

安装vsftpd

检测是否已经安装vsftpd。

[root@localhost ~]# rpm -qa | grep vsftpd
[root@localhost ~]#

什么都不显示就没有安装

安装vsftpd

使用yum安装
[root@localhost ~]# yum -y install vsftpd
使用rpm安装
[root@localhost local]# rpm -ivh vsftpd-3.0.2-21.el7.x86_64.rpm 

启动服务

[root@localhost local]# service vsftpd start
Redirecting to /bin/systemctl start vsftpd.service

查看服务状态

[root@localhost local]# service vsftpd status
Redirecting to /bin/systemctl status vsftpd.service
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
Active: active (running) since 三 2017-08-30 15:28:18 CST; 15min ago
Process: 4295 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 4296 (vsftpd)
CGroup: /system.slice/vsftpd.service
└─4296 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf 8月 30 15:28:18 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...
8月 30 15:28:18 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.
Hint: Some lines were ellipsized, use -l to show in full.

Active: active (running) 启动状态,可以使用

现在我们就可以匿名访问了

vsftpd添加用户

vsftpd添加用户

FTP用户一般是不能登录系统的,只能进入FTP服务器自己的目录中,这是为了安全.这样的用户就叫做虚拟用户了.实际上并不是真正的虚拟用户,只是不能登录SHELL了而已,没能力登录系统.

添加用户命令

/usr/sbin/adduser -d /opt/test_ftp -g ftp -s /sbin/nologin test2

上面的命令是添加一个 名称为 test2的用户。

命令解析:使用命令(adduser)添加test2用户,不能登录系统(-s /sbin/nologin),自己的文件夹在(-d /opt/test_ftp)),属于组ftp(-g ftp).

为该用户设置密码

[root@localhost local]# passwd test2

现在重启服务我们就可以使用test2直接访问我们的 /opttest_ftp目录了

给用户权限上传下载,修改

虽然用户能够进行查看,但是还没有权限上传、下载和修改

授权

[root@localhost local]# chmod 755 /opt/test_ftp

编辑配置文件

一般创建一个ftp 用户,作为管理员只希望它只能访问其自己的所属目录的,是不会让他选择其他目录的。

设置ftp用户的权限

在安装好ftp时,在 /etc/vsftpd目录下可以看到vsftpd的配置文件vsftpd.conf

[root@localhost vsftpd]# vim 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.
# When SELinux is enforcing check for SE bool ftp_home_dir
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.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
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
#
# 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/xferlog
#
# 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 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
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
# vsftpd:500 OOPS: vsftpd: refusing to run with writable root inside chroot ()错误的解决方法
allow_writeable_chroot=YES
#
# 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. 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.
# Make sure, that one of the listen options is commented !!
# listen_ipv6=YES pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
anon_other_write_enable=YES
#anon_root=/opt/test_ftp
#guest_enable=YES
#guest_username=test2
virtual_use_local_privs=YES

用户访问权限及路径限制:

如果 userlist_deny=NO:只允许userlist_file文件中的用户可访问ftp;如果 userlist_deny=YESuserlist_file文件中列举的用户不能通过ftp访问系统。userlist_enable是该功能的开关。我们的系统配置如下:

userlist_enable=YES
userlist_deny=NO
userlist_file=/etc/vsftpd/user_list

把需要登录的用户加入到/etc/vsftpd/user_list文件中,一个用户一行。

如果我们不需要把登陆的用户限制在主目录下需要一下配置:

进入主配置文件中chroot_list_enable=YES

创建用户文件/etc/vsftpd/chroot_list

vim /etc/vsftpd/chroot_list

将不需要限制的用户添加进去,我们只有一个test2,一行一个用户名

ps: 这些用户将能访问全部有权限的文件。

设置权限

[root@localhost vsftpd]# getsebool -a|grep ftp
ftpd_anon_write --> off
ftpd_connect_all_unreserved --> off
pd_connect_db --> off
▽tpd_full_access --> off
ftpd_use_cifs --> off
ftpd_use_fusefs --> off
ftpd_use_nfs --> off
ftpd_use_passive_mode --> off
httpd_can_connect_ftp --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_home_dir --> off
开启 anon_write 和full_access
[root@localhost vsftpd]# setsebool allow_ftpd_anon_write  1
[root@localhost vsftpd]# setsebool allow_ftpd_full_access 1

重启ftp服务

[root@localhost vsftpd]# service vsftpd restart 

测试

注:测试连接软件是FileZilla,windows访问 ftp://[ip]

update 20170901 使用FileZilla创建中文文件夹Linux乱码

首先出现这个问题的原因是WINDOWS采用的是GBK编码方式,而Linux采用的是UTF-8

首先设置好FileZilla的编码方式为zh_CN

在将 /etc/locale.conf 中的LANG修改为"zh_CN.UTF-8"

[root@localhost ~]# vim /etc/locale.conf
LANG="zh_CN.UTF-8"

这个修改可以有效解决windows客户端使用ftp协议上传中文文件到Linux乱码的问题。

其实最根本的解决方法是客户端上传的文件经过ftp软件能与服务器统一编码方式,具体百度吧c#、java的都有。

博客地址

linux上搭建ftp服务器的更多相关文章

  1. CentOS Linux上搭建PPPoE服务器及拨号设置

    CentOS Linux上搭建PPPoE服务器及拨号设置 搭建PPPoE,成功了的话,就觉得超级简单,在CentOS Linux更是5步左右就能搞定. 1.安装pppoe,安装完成后,会有pppoe- ...

  2. linux上构建ftp服务器

    linux上构建ftp服务器 服务器搭建 https://help.aliyun.com/knowledge_detail/60152.html,可以参考这篇博文. 配置文件详解 进入/etc/vsf ...

  3. 【转】Linux环境搭建FTP服务器与Python实现FTP客户端的交互介绍

    Linux环境搭建FTP服务器与Python实现FTP客户端的交互介绍 FTP 是File Transfer Protocol(文件传输协议)的英文简称,它基于传输层协议TCP建立,用于Interne ...

  4. linux上搭建ftp

    linux上搭建ftp 重要 解决如何搭建ftp         解决用户指定访问其根目录         解决访问ftp超时连接         解决ftp主动连接.被动连接的问题 1.安装ftp ...

  5. linux上搭建ftp、vsftp, 解决访问ftp超时连接, 解决用户指定访问其根目录,解决ftp主动连接、被动连接的问题

    linux上搭建ftp 重要 解决如何搭建ftp         解决用户指定访问其根目录         解决访问ftp超时连接         解决ftp主动连接.被动连接的问题 1.安装ftp ...

  6. Linux上的ftp服务器vsftpd之配置满天飞--设置匿名用户访问(不弹出用户名密码框)以及其他用户可正常上传

    一.问题背景 没事谁折腾这鬼玩意哦...还不是因为bug. 我们的应用,用户头像是存在ftp上的.之前的ftp服务器是一台windows,我们后台服务器程序收到用户上传头像的请求时,会用一个ROOT/ ...

  7. 【转】【FTP】之windows8.1上搭建FTP服务器方法

    参考地址:<windows8.1上搭建FTP服务器方法>

  8. linux系统搭建ftp服务器及创建用户使用

    linux 系统下搭建ftp服务器 ftp是什么 FTP是 File Transfer Protocol 文件传输协议的英文名称,用于在Internet上控制文件的双向传输. 同时它也是一个应用程序. ...

  9. 如何在windows上搭建ftp服务器

    FTP(File Transfer Protocol)是TCP/IP网络上两台计算机传送文件的协议,使得主机间可以共享文件.目前有很多软件都能实现这一功能,然而windows自带的IIS就可以帮助你搭 ...

随机推荐

  1. Java基础---Java---IO流-----BufferedReader、BufferedWriter、缓冲区、装饰设计模式及和继承的区别

    IO流 IO流用来处理设备之间的数据传输 java对数据的操作是过流的方式 流按操作数据分为两种:字节流与字符流 流按流向分为:输入流,输出流. IO流常用基类 字节流的抽象基类:InputStrea ...

  2. android之.9.png详解

    .9.PNG是安卓开发里面的一种特殊的图片,这种格式的图片通过ADT自带的编辑工具生成,使用九宫格切分的方法,使图片支持在android 环境下的自适应展示. PNG,是一种非失真性压缩位图图形文件格 ...

  3. (八十)MapKit放置系统默认大头针和自定义大头针

    有关MapView的显示和定位在上一节已经说明,这一节说明如何在地图上放置大头针,以及设置点击大头针的视图. [系统默认大头针] mapView上放置大头针的方法是调用其addAnnotation:方 ...

  4. Cocos2D中的纹理(textures)的解释

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 免责申明:本博客提供的所有翻译文章原稿均来自互联网,仅供学习交流 ...

  5. Git版本控制:Gitlab及Coding.net的使用

    http://blog.csdn.net/pipisorry/article/details/50709014 Gitlab介绍 GitLab是利用 Ruby on Rails 一个开源的版本管理系统 ...

  6. EBS DBA指南笔记(二)

    第三章 监控和诊断   本章涵盖以下几个主题:监测的方法,数据库的监测,apache的监测,forms的监测,并发管理器的监测,服务器的监测,网络的监测,其它的一些监测和诊断方法. 1.监测的方法:主 ...

  7. java中Error与Exception有什么区别

    Error类和Exception类都继承自Throwable类. Error的继承关系: java.lang.Object  java.lang.Throwable      java.lang.Er ...

  8. 海量数据挖掘MMDS week5: 计算广告Computational Advertising

    http://blog.csdn.net/pipisorry/article/details/49428053 海量数据挖掘Mining Massive Datasets(MMDs) -Jure Le ...

  9. Linux IPC实践(4) --System V消息队列(1)

    消息队列概述 消息队列提供了一个从一个进程向另外一个进程发送一块数据的方法(仅局限于本机); 每个数据块都被认为是有一个类型,接收者进程接收的数据块可以有不同的类型值. 消息队列也有管道一样的不足:  ...

  10. 软考之路--J2SE,从HelloWorld到传世代码

    "Hello World"程序指的是只在计算机屏幕上输出"Hello, World!"(意为"世界,你好!")这行字符串的计算机程序.hel ...