如何在LINUX(UBUNTU)实现FTP服务器多用户多权限

2023-05-16

要求

实现两个用户,使得一个student可以上传,下载文件

另一个teacher可以上传,下载,删除文件

首先现在Ubuntu上安装ftp(以下使用vsftp演示)

//1.安装vsftpd
sudo apt-get install vsftpd
​
//2.检验是否按照成功
vsftpd -v
or
service vsftpd status
​
//3.修改vaftpd配置文件
/*
找到listen=YES
listen_ipv6=NO
将YES改为NO,将NO改为YES(因为我们一般使用ipv4)
*/
​
//4.添加用户组,将我们所需要的用户全部放到同一个组中进行
sudo groupadd ftpuser
​
//接下来我们有两种方法创建用户
1.使用adduesr + 用户名直接创建,此方法的好处就是实现了人机交互,较为方便
2.使用adduser + 用户名创建,之后再为其修改密码,修改参数即可
​
我们采用第二中方法
//5.创建用户
//5.1首先,再根目录下创建一个guest目录
mkdir /home/guest/(用于存放用户)
​
//添加teacher用户到用户组ftpuser中
sudo useradd -g ftpuser student
​
//为teacher设置密码
passwd teacher
​
//修改shell和权限
vim /etc/passwd
找到对应用户
将其末尾修改为:/bin/bash
//更改文件所有者的权限
chown -v -R teacher:ftpuser /home/guest
chmod -v -R 700 /home/guest
​
//重启服务
service vsftpd restart
​
//再linux终端输入ftp localhost即可访问fpt服务器
​
//同样的,使用类似的方法可以创建teacher用户

为了使student用户没有删除的权力,需要做以下更改

//首先新建一个文件夹
mkdir -p /etc/vsftpd_user_conf
​
//然后在该文件夹中创建一个文件并写入cmds_denied=DELE即可
vim ./你想要禁用的用户名
//此处为student
vim student
​
//重新打开配置文件
vim /etc/vsftpd.conf
//写入
user_config_dir=/etc/vsftpd_user_conf
​
//重启ftp服务即可

ftp服务器配置文件如下

# 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=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.
listen_ipv6=NO
#
# Allow anonymous FTP? (Disabled by default).
anonymous_enable=NO
#
# 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=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.
listen_ipv6=NO
#
# 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
# (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=vsftpd
#
# 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
#
allow_writeable_chroot=YES
​
​
#jingzhiguest(student)shanchu wej 
user_config_dir=/etc/vsftpd_user_conf


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在LINUX(UBUNTU)实现FTP服务器多用户多权限 的相关文章

  • android N进程启动流程(一)(捕获输入事件、准备创建activity、焦点切换)

    android N进程启动流程 一 捕获输入事件 准备创建activity 焦点切换 1 背景 本文主要针对event log中各处节点进行进程启动流程分析 span class token comment 此处使用的是adb指令input
  • 目标检测类前言知识

    1 PASCAL数据集 有关目标检测 xff0c 目标分类 xff0c 目标分割 xff0c 动作识别 1 xff09 下载的数据集文件介绍 标注信息 xff1a xml文件实例 xff1a lt segmented gt 1 被分割 0
  • 最新网狐荣耀版整理、编译和搭建教程

    一 安装visual studio 2015 xff0c 在百度就能搜索到下载地址 xff0c 在教程最后 xff0c 会给大家包括所有工具在内的集成包 因为visual studio 2015体积比较大 xff0c 而且安装过程很漫长 x
  • windows efi分区修复

    在windows下一阵瞎搞 xff0c 把efi分区的efi标识搞没了 xff0c 导致deepin无法识别efi分区 xff0c update grub2命令失败 其实windows也找不到efi标识了 xff0c 但没有影响启动 因为W
  • XML 根级别上的数据无效。 行 1,位置 1

    上午 xff1a 将XML数据保持到数据中 xff0c 从数据库提取XML 顺利通过 下午 xff1a 一键还原电脑 xff0c 重新打开VS2010运行程序 xff0c 从数据库提取XML报错 根级别上的数据无效 行 1 xff0c 位置
  • 接触客户、接触业务、来谈我的感触

    很久没有做工作总结 xff0c 今天记录下我今年接触客户的一些感触 以前是一个刚入门的开发新人 xff0c 刚进公司感觉公司的开发能力不行 xff0c 没有一套成熟的框架 xff0c 没有美工 xff0c 已经开发出的软件界面很丑 自己开发
  • 编写一个函数,判断用户传入的对象(字符串,列表,元组)长度是否大于10

    span class token keyword def span span class token function my object span span class token punctuation span n span clas
  • 双盘(一个固态硬盘+机械硬盘(efi格式)+2080TI) 安装: ubuntu16.04+显卡驱动+cuda10.2+pytorch

    详细步骤 xff1a 从零开始配一个深度学习服务器 xff1a 固态 43 机械双硬盘ubuntu系统的安装 分区 配置超详细教程 it610 com 一 系统安装 Ubuntu6 04安装 UEFI 43 GPT双硬盘安装Win10 43
  • Idea java.lang.ClassNotFoundException: org.slf4j.LoggerFactory 报错

    系统想用slf4j记录日志 xff0c 可是程序编译的时候报错 xff1a java lang ClassNotFoundException org slf4j LoggerFactory 检查了POM依赖和Jar包 xff0c 都没有问题
  • 小米2020校招软件开发工程师笔试题一

    1 下列关于设计模式说法错误的是 xff08 B xff09 A 装饰器模式在实现过程中一般不会更改被封装对象的接口定义 B 适配器模式以不改变被适配对象的接口定义为目的对其进行改造 C 用饿汉方式实现的单例模式是不能够被继承的 D 简单工
  • vscode1.70.2 添加终端 powershell7

    前提已经安装号powershell7 xff0c 并且已经添加到系统环境中 如何测试是否配置成功呢 xff0c 在运行中输入pwsh xff0c 点击确定后能打开powershell7就说明成功了 打开vscode的设置 xff0c 搜索
  • twm配置文件.twmrc

    系统的twmrc文件位于 usr X11 twm目录下 xff0c 为system twmrc xff0c 但是修改这个文件是不生效的 xff0c 必须将这个文件拷到 HOME下 xff0c 重命名为 twmrc才生效 twm有一个特别奇怪
  • Redis缓存型数据库实现秒杀库存加减

    多线程并发下商品库存递减或者抢购商品数量累加 xff0c 可以使用increment 方法 通常使用异步的方式 xff0c 前端 61 gt 用户抢购处理 61 gt 缓存 61 gt 队列 61 gt 持久化 xff0c 可以使用入队列的
  • Java项目:医院住院管理系统(java+SSM+JSP+bootstrap+mysql)

    源码获取 xff1a 俺的博客首页 34 资源 34 里下载 xff01 项目介绍 本项目有多种角色 xff0c 包含管理员 用户 护士 服务前台等角色 由于篇幅限制 xff0c 只截图了管理员角色的功能 管理员角色主要功能包括 xff1a
  • 直接使用X11输出图像的方法

    直接使用X11输出图像有两种方法 xff0c 一种是使用XImage xff0c 另一种是使用Pixmap XImage是本地对象 xff0c 而Pixmap是XServer端对象 特别要注意的是X11中Bitmap是黑白位图的意思 xff
  • python文件读写的缓冲行为

    文件的io操作的缓冲行为分为 全缓冲 xff1a 同系统及磁盘块大小有关 xff0c n个字节后执行一次写入操作 行缓冲 xff1a 遇到换行符执行一次写操作 无缓冲 xff1a 立刻执行写操作 open 函数 help open Help
  • 在Linux中使用systemctl如何管理Systemd服务和单元

    Systemctl是一个systemd工具 xff0c 它负责控制systemd系统和服务管理程序 Systemd是一个系统管理守护进程 xff0c 工具和库的集合 xff0c 它用作替换System V init守护进程 Systemd功
  • iOS中的viewpager,开源库WMPageController在storyboard中的使用

    http blog csdn net yubo 725 article details 51159633 关于WMPageController的使用以上链接写的很清楚 xff0c 在此感激博主 android 中有viewpager xff
  • 约瑟夫环问题研究(一)

    最近在看C方面的东西 xff0c 看到了李明老师讲解的约瑟夫环问题 xff0c 感觉很有意思 xff0c 于是在看了他的讲解之后 xff0c 自己又重新按照他的思路进行了编写 xff0c 整理如下 xff1a 问题描述 xff1a 约瑟夫环
  • HDOJ 题目2050 折线分割平面(递推)

    折线分割平面 Time Limit 2000 1000 MS Java Others Memory Limit 65536 32768 K Java Others Total Submission s 16441 Accepted Subm

随机推荐

  • HPUOJ 题目1079 假币问题(三分)

    1079 假币问题 时间限制 1 Sec 内存限制 128 MB 提交 7 解决 1 提交 状态 讨论版 题目描述 居然有假币 xff01 xff01 xff01 事情是这样的 xff0c 现在猪肉涨了 xff0c 但是农民的工资却不见涨啊
  • HPUoj 题目1019 【C语言训练】尼科彻斯定理(水题,数学)

    1019 C语言训练 尼科彻斯定理 时间限制 1 Sec 内存限制 128 MB 提交 9 解决 5 提交 状态 讨论版 题目描述 验证尼科彻斯定理 xff0c 即 xff1a 任何一个正整数的立方都可以写成一串连续奇数的和 输入 任一正整
  • POJ 题目1105 S-Trees(二叉树模拟)

    S Trees Time Limit 1000MS Memory Limit 10000KTotal Submissions 1499 Accepted 807 Description A Strange Tree S tree over
  • FOJ 题目 2075 Substring (后缀数组求出现k次的最小字典序子串)

    Problem 2075 Substring Accept 70 Submit 236 Time Limit 1000 mSec Memory Limit 65536 KB Problem Description Given a strin
  • 认识onNewIntent

    前几天面试被问到onNewIntent 我竟哑口无言 完全没听过这个东西 xff0c 所以总结经验教训 xff0c 多学习吧 一个简单的例子说明 xff1a activityA 启动activityB 并通过intent传递了一些数据 xf
  • 操作系统——作业

    写在前头 xff1a 这是小鱼上的网课整理来的笔记 xff0c 希望可以帮助大家更好的理解操作系统这门课 xff01 一 作业 这一讲 xff0c 我们来介绍作业的概念 我们需要从两个方面去理解作业 1 用户 我们可以先看看下面的图示的编译
  • 手把手教学在Springboot中搭建使用Guava cache,包教包会,不会我输一包辣条给你

    guava cache使用简介 概述 缓存是日常开发中经常应用到的一种技术手段 xff0c 合理的利用缓存可以极大的改善应用程序的性能 Guava官方对Cache的描述连接 缓存在各种各样的用例中非常有用 例如 xff0c 当计算或检索值很
  • Ubuntu使用Glmark2进行跑分

    Ubuntu使用Glmark2进行跑分 Glmark2 是一个基于 OpenGL 2 0 和 OpenGL ES 2 0 开发的benchmark程序 xff0c 主要用于对GPU的基准测试 安装和运行 Glmark2 安装依赖的开发工具
  • Ubuntu 22.04 安装Fcitx5中文输入法

    Ubuntu 22 04 安装Fcitx5中文输入法 一 检查系统中文环境 在 Ubuntu 设置中打开 区域与语言 管理已安装的语言 xff0c 然后会自动检查已安装语言是否完整 若不完整 xff0c 根据提示安装即可 二 安装Fcitx
  • AHU 2022 CTF新生赛web_writeup

    第一次当出题人 xff0c 给新生做的 xff0c 简简单单啦 按不了的F12 启动靶机 xff1a 根据题目名称可知 xff0c 这题与f12按键有关 xff0c 即查看网页源代码 按下f12发现f12按键被禁用 xff1a 尝试另一种方
  • 基于OpenAI实现的个人助理

    基于OpenAI实现的个人助理 最近OpenAI所开发的ChatGPT非常火 xff0c 于是我也去体验了一下 在玩过之余 xff0c 就想着能不能把它移植到系统环境 xff0c 成为一个日常的个人助理 xff0c 帮助我解决学习 开发或者
  • 基于OpenAI的Chatbot开发记录

    Chatbot 开发记录 最近ChatGPT非常火 xff0c 去体验之后确实有被惊艳到 xff0c 也对OpenAI上的人工智能模型比较感兴趣 xff0c 于是想着复刻一个ChatGPT xff0c 利用官方提供的包和api xff0c
  • 使用WebSocket实现异地同步看电影

    使用WebSocket实现异地同步看电影 项目地址 xff1a https github com Fangnan700 Film room 说明 放假回家之后 xff0c 因为和女朋友不在同一个地方 xff0c 又想着一起看电影 xff0c
  • 写一个AI小助手

    AI aides 本项目最初只是想对GPT 3模型进行一个封装 xff0c 后来发现了由 acheong08 大佬提供的接口 xff0c 于是将这个AI小助手进行了接入 xff0c 部署到服务器上后即可使用 本项目基于Python 和 un
  • 我在终端里养了个猫娘

    Kira 一个知识丰富且超级温柔的猫娘 x1f36d 食用指南 本项目是一个终端小程序 xff0c 智慧且温柔的猫娘Kira让你的终端不再单调乏味 第0步 在计算机合适的位置创建一个文件夹 xff0c 到本项目的release页面下载对应系
  • git pull命令的用法

    git pull用法 xff1a git pull命令的作用是 xff1a 取回远程主机某个分支的更新 xff0c 再与本地的指定分支合并 一句话总结git pull和git fetch的区别 xff1a git pull 61 git f
  • 《C++高效编程:内存与性能优化》第九章:高效内存管理

  • ubuntu安装chrome报错解决

    直接双击软件中心会报错 用命令安装也会报下面这个错 dpkg dependency problems prevent configuration of google chrome stable google chrome stable de
  • pycurl的学习之路

    pycurl的模块用法 c 61 pycurl span class hljs preprocessor Curl span span class hljs preprocessor 创建一个curl对象 span c span class
  • 如何在LINUX(UBUNTU)实现FTP服务器多用户多权限

    要求 实现两个用户 xff0c 使得一个student可以上传 xff0c 下载文件 另一个teacher可以上传 xff0c 下载 xff0c 删除文件 首先现在Ubuntu上安装ftp xff08 以下使用vsftp演示 xff09 1