一、问题背景

没事谁折腾这鬼玩意哦。。。还不是因为bug。

我们的应用,用户头像是存在ftp上的。之前的ftp服务器是一台windows,我们后台服务器程序收到用户上传头像的请求时,会用一个ROOT/ROOT的账户,连接ftp服务器。

获取到连接后,即进行上传。

上传:上传文件则存放在ROOT用户的home 目录(在windows上装的是server-U来充当ftp服务器,所以就是在Server-U里面配置了ROOT用户的home目录)。

上传完成后,会得到一个ftp协议类型的url。范例如:

ftp://10.10.20.2/userphoto/user7.png。

客户端拿到该url后,即用ftp客户端的库连接该url,获取到文件流,下载下来,进行展示。

这两天,ftp服务器从windows变到了redhat上。今天下午,测试突然报了个bug过来,说是用户头像不能正常展示了。what?于是开始查找问题。

梳理了半天,发现问题在于:linux上的ftp服务器,采用的是vsftpd软件。因为配置文件没配好的原因,利用前面的“ftp://10.10.20.2/userphoto/user7.png”就访问不到图片。

为什么说没配好呢,一开始报的错是:FTP 550 Failed to change directory

于是按照下面博文里的进行修改:https://blog.csdn.net/coreyC/article/details/80866533

没想到一波三折。

二、匿名访问

关于匿名访问,如果不成功的话,那么,请首先去下载一个工具,winscp。

按照下面的方式去进行匿名访问:

如果匿名登录失败的话,会提示具体的原因。

三、匿名上传

错误提示1:553 Could not create file

这个提示,有一个原因是,匿名用户的主目录,主目录的意思是,每个用户登录进去后所在的目录,后续的读取、上传都会在这个目录,相当于用户的base目录吧。

如果主目录的权限不够,就会提示这个问题,一般直接野蛮改为777权限。

至于主目录在哪? 在配置文件中通过以下选项进行配置:

anon_root=/data/ftp

如下图所示,需要把主目录权限改为777,即可匿名上传:

修改权限的命令:

 chmod  /data/ftp

下述的报错也是同样的问题:

500 OOPS: vsftpd: refusing to run with writable anonymous root

二、支持匿名访问/上传的配置文件

正确的配置贴一份,这份配置再加上,对目录进行必要的权限设置,基本可以摆平大多数情况:

# 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. for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf. 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

#https://blog.csdn.net/bluishglc/article/details/42399439
  allow_writeable_chroot=YES

#
# Uncomment this to allow local users to log in.
# 之前说到我们用ROOT/ROOT来访问ftp,我们这里,ROOT/ROOT是我们的linux可以登录的用户名密码。要允许这类用户访问ftp,需要开启下面的选项
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
# 要允许写入操作。否则应该不能上传文件
write_enable=YES
#
# Default umask for local users is . You may wish to change this to ,
# if your users expect that ( is used by most other ftpd's)
local_umask=
#
# 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.
# 匿名上传,需要配合write_enable=yes
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
#控制匿名用户对文件和文件夹的删除和重命名
anon_other_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 (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=
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=
#
# 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_local_user=YES
#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 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_root=/home/ROOT
#匿名用户不要密码就靠这个
no_anon_password=YES
#本地用户,如我们上传用的用户(ROOT/ROOT)的根目录。当然,我们给匿名配了那么多,估计匿名也能上传了。
local_root=/home/ROOT
#该选项暂时不太清楚
ftp_username=ROOT

参考资料:

https://blog.csdn.net/haoge921026/article/details/51956983

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

  1. linux centos6.5 ftp网页vsftpd配置

    安装命令centos下 yum install vsftpd 出现“Complete!”时意味着安装完成.Linux中,系统对于大小写严格区分,比如abc和ABC是完全不相同的字符,要特别注意.配置V ...

  2. 腾讯云服务器linux centOS7.4 搭建ftp服务器 vsftpd

    腾讯云服务器linux centos 7.4 搭建ftp服务器 vsftpd 在centos 7.3测试也是OK的,其它版本没有实验 # 安装 vsftpd $ yum install vsftpd ...

  3. 腾讯云服务器linux Ubuntu操作系统搭建ftp服务器vsftpd

    腾讯云服务器linux Ubuntu操作系统安装ftp服务器vsftpd 操作系统: Ubuntu Server 16.04.1 LTS 64位 下面我将系统重装, 一步一步从头开始,安装FTP服务器 ...

  4. linux上构建ftp服务器

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

  5. 在windwo server2008服务器上配置ftp服务器、及配置phpstrom工具、实现项目同步。

    在windwo server2008服务器上配置ftp服务器.及配置phpstrom工具.实现项目同步. 在windwo server2008服务器上配置ftp服务器 参考该篇文章:http://bl ...

  6. centos 6.5 搭建ftp 服务器(vsftpd的配置文件说明)

    0x00 如何快速的搭建简易的资源发布站 开启简易的python http服务器 1 2 cd /home/your_path python -m SimpleHTTPServer 8000 开启防火 ...

  7. Linux安装部署FTP服务器

    Linux安装部署FTP服务器   本文章会将安装FTP服务器的步骤以及一些遇到的问题来记录下 因为项目中要与第三方对接数据,需要用到FTP服务器以提供他们每天上传数据,因为之前在本地的VMware虚 ...

  8. 在CentOS7上安装ftp服务器用于保存服务端上传的图片。

    1.CentOS卸载vsftpd的方法 如果服务器上已经安装了vsftpd服务,配置出错需要卸载vsftpd服务. 1.1 查找vsftpd服务 [root@localhost /]# rpm -aq ...

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

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

随机推荐

  1. 软渲染 SoftRender

    弄了这几年OpenGL对管线还是算比较熟悉,写起来也比较顺,不过每个顶点都要经过一堆变换,着实感到效率的重要.(矩阵乘顶点没有SSE加速啊)装个B,半天的成果..(主要很多东西都写好了直接拿来) // ...

  2. mysql 5.1超过默认8小时空闲时间解决办法(错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure)

    报错: MySQL第二天早上第一次连接超时报错, com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications lin ...

  3. eclipse中去掉validate的方法

    昨天在右击项目想选择refresh的时候一不小心选择了validate,就发现target包出现了红色的叉号.当时觉得反正项目运行没有什么异常,就这么凑合了一天半多. 后来,当我改jsp的时候从< ...

  4. rdlc报表 矩阵控件下的按组分页

    场景: 使用rdlc开发报表,例如订单产品报表,显示多个订单,一个订单有动态生成的固定的多个产品组成,同时统计每个订单里多个产品数量总数. 数据库层面分析: 此报表属于交叉报表,例如5个订单,3个产品 ...

  5. UNIX环境编程学习笔记(7)——文件I/O之文件访问权限与进程访问控制

    lienhua342014-09-02 1 文件的设置用户 ID位 和设置组 ID位 与进程相关联的 ID 如下表所示, 表 1: 与进程相关联的用户 ID 和组 ID 实际用户 ID 我们实际上是谁 ...

  6. MSM--Memcached_Session_Manager介绍及使用

    MSM--Memcached_Session_Manager介绍及使用 http://www.iteye.com/topic/1125301 我们都知道对于一些大型的web2.0的网站,在正式部署时一 ...

  7. VSCode升级后启动不了~

    之前安装了VSCode,一直用的好好的,每次启动后后下角总会提示自己有新版本可以更新,然后就手贱点击了更新,然后就出问题了,更新后VSCode无法启动,打不开了,哭死! 于是,我尝试了以下方法,均无济 ...

  8. PHP代码审计笔记--SQL注入

    0X01 普通注入 SQL参数拼接,未做任何过滤 <?php $con = mysql_connect("localhost","root"," ...

  9. YUV格式学习笔记

    YUV与RGB表现图像的方法不同,其采用的是一个亮度信号加两个色差信号的方式来表现图像.其中UV表示的是CbCr,常见的YUV格式有:YUV4:2:0,YUV4:2:2,YUV4:1:1,YUV4:4 ...

  10. Splash 对象方法

    go() wait() jsfunc() evaljs() runjs() autoload() call_later() http_get() http_post() set_content() h ...