摘要

上篇文章介绍了如何为ftp添加虚拟用户,本篇将继续实践如何上传,下载文件。

上传

使用xftp客户端上传文件,如图所示

此时上传状态报错,查看详情

从错误看出是应为无法创建文件造成的。那么我们就要修改ftp服务器的配置了。

授权

chmod 755 /opt/test_ftp  // 给予文件夹的操作权限

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

设置ftp用户的权限

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

进入目录

cd /etc/vsftpd 

查看列表

ls

编辑配置文件

vi  vsftpd.conf

将用户(一般指虚拟用户)限制在自家目录
修改配置文件中,这样用户就只能访问自己家的目录了:

chroot_local_user=yes

重启ftp

service vsftpd restart

使用xftp客户端,进行尝试。

ftp配置文件

# 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 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=YESpam_service_name=vsftpd
userlist_enable=YES
anon_other_write_enable=YES
tcp_wrappers=YES
anon_root=/opt/test_ftp
guest_enable=YES
guest_username=wolfyftp
virtual_use_local_privs=YES

设置权限

使用命令

getsebool -a|grep ftp

getsebool,列出所有selinux bool数值清单列表与内容。

allow_ftpd_anon_write --> on
allow_ftpd_full_access --> off

开启 anon_write 和full_access

setsebool allow_ftpd_anon_write  1

etsebool allow_ftpd_full_access 1

重启ftp服务

service vsftpd restart

测试

在本地使用xftp客户端进行上传,下载,删除,重命名,操作。如图

总结

设置权限,感觉只需配置文件中配置对了,然后将full_access 设置为1 就可以了。

转载于:https://www.cnblogs.com/wolf-sun/p/6074614.html

[CentOs7]搭建ftp服务器(3)——上传,下载,删除,重命名,新建文件夹相关推荐

  1. linux搭建ftp服务器可上传下载,通过linux系统搭建ftp服务然后使用filezilla客户端进行上传下载...

    1.         准备环境 一台linux主机作为ftp服务器(这里以centos7.2系统为例),一台Windows系统的主机作为客户端 2.         服务端配置: (1)   下载vs ...

  2. SpringBoot 搭建图片服务器 -- 支持上传下载和浏览

    前言: 项目需求:做一个图片服务器,用于存放业务部门做的宣传图片:支持上传.下载和在线查看. 一.需求分解 1. 上传.下载功能比较成熟,相对好实现: 2. 在线预览,需要分为单个文件预览和多个文件预 ...

  3. linux上连接ftp服务器,linux下lftp连接ftp服务器进行上传与下载的方法详解

    摘要 腾兴网为您分享:linux下lftp连接ftp服务器进行上传与下载的方法详解,中英翻译,中建在线,掌上看家,银行帮等软件知识,以及微信一键转发工具,小学英语冀教版,正是在下表情包,易问电信,万能 ...

  4. 怎么上传ftp服务器文件,ftp服务器如何上传本地文件

    ftp服务器如何上传本地文件 内容精选 换一换 在本地主机和Windows弹性云服务器上分别安装QQ.exe等工具进行数据传输.使用远程桌面连接mstsc方式进行数据传输.该方式不支持断点续传,可能存 ...

  5. 拖拽文件夹上传 一(基于Vue的文件夹上传组件)

    前言 首先说一下,小弟第一次写文章,如果有什么错误 还望小哥哥 小姐姐多多包涵.如果有什么缺陷还望大家指出来 让小弟多学习. 内容划分 上传文件夹一共分两部分来写 一方面怕太长了 大家看五分钟就不想看 ...

  6. python图片重命名 工具_python - 请问django如何给上传的图片重命名

    问 题 我的models.py: pic = models.ImageField(upload_to='img/%Y/%m') 怎样给上传的图片重命名?例如:以当前上传的时间给图片命名.谢谢~! 解决 ...

  7. web上传文件到ftp服务器,web 上传文件到ftp服务器上

    web 上传文件到ftp服务器上 内容精选 换一换 安装传输工具在本地主机和Windows云服务器上分别安装数据传输工具,将文件上传到云服务器.例如QQ.exe.在本地主机和Windows云服务器上分 ...

  8. ftp服务器只能上传文件,ftp服务器上传文件不行

    ftp服务器上传文件不行 内容精选 换一换 本文介绍如何在 Linux 系统的本地机器上使用 FTP 服务,将文件从本地上传到云服务器中.已在待上传文件的云服务器中搭建 FTP 服务.如果您的云服务器 ...

  9. ftp服务器批量上传文件,bat批量上传ftp文件到服务器

    bat批量上传ftp文件到服务器 内容精选 换一换 CDM支持周期性自动将新增文件上传到OBS,不需要写代码,也不需要用户频繁手动上传即可使用OBS的海量存储能力进行文件备份.这里以CDM周期性备份F ...

最新文章

  1. 汇编语言求无符号数组中出现的次数最多数_【今日最佳leecode通俗易懂】无重复字符的最长子串...
  2. sqlserver清除日志
  3. php返回null接收的是空字符串,求大神救命!!php接收到是空的字符串
  4. 看完这一篇,再也不用担心 Git 的“黑魔法”
  5. leetcode刷题 2.两数相加
  6. Hibernate框架之入门配置
  7. android驱动代码,GitHub - rumengsuifeng/AndroidDrivers: Android驱动的代码
  8. MySQL基础篇(06):事务管理,锁机制案例详解
  9. 3.2_栈_链式存储结构(链表形式)
  10. 微信开发(一)SAE环境搭建
  11. C#中取得汉语拼音首字母
  12. 理解 loss function : binary cross entropy
  13. 远程计算机关机了怎么办,远程关机的详细步骤有哪些?向日葵怎么远程关机?...
  14. SAP 离散,流程,重复制造
  15. Room的基本使用(一)
  16. 录屏怎么录声音?注意一点轻松录制外部音源
  17. 纵轴上每个单位长度表示什么_6.5 坐标轴:1是几?坐标轴上的单位长度的相对大小(拗口)...
  18. 弹性盒子flex轴的说明
  19. Android微信抢红包插件原理和实现 适配微信6.6.1版本
  20. 自学实前后端践项目4 MMall商城 1

热门文章

  1. Python可视化工具Matplotlib 3.0版出炉,改进默认后端选择,饼图终于变圆了
  2. CNCC2018:[早鸟票]倒计时两周,7000人盛会日程抢先看!
  3. 百度英伟达联手推混合精度训练,同样性能只需一半内存 | 附论文
  4. 陈天石吴翰清顾嘉唯光速对话(汤晓鸥今天没有晒娃)
  5. 纳达尔复出迎澳网开门红 直落三盘横扫本土选手
  6. React-Native入门(2)-简单阐述跳转
  7. ansible执行拷贝/脚本/任务计划/yum/service
  8. 数据库之Oracle
  9. spring MVC interceptor post遇到问题
  10. private、public、protected、internal修饰符的访问权限