ftp用户个性化精准权限设置

以用户名“devicelog”为例,列出配置ftp用户权限的方法

1.ftp添加用户,创建并设置主目录,限定只能用于ftp登录

useradd -d/ftpdata/devicelog -g ftp -s /sbin/nologin devicelog

 

2.为devicelog设置密码

passwd devicelog

按提示输入两次密码,输入时密码是隐藏的。

 

3.修改用户登入后所使用的shell

usermod -s /bin/bashdevicelog

 

4.编辑login.txt 文件,奇数(单数)行为用户名,偶数(双数)行为密码

devicelog

devicelog12345

 

5.生成db文件

db_load -T -t hash -f/etc/vsftpd/login.txt /etc/vsftpd/login.db

 

6.编辑(不存在则新建)vi /etc/pam.d/vsftpd.vu

auth required/lib64/security/pam_userdb.so db=/etc/vsftpd/login

account required  /lib64/security/pam_userdb.sodb=/etc/vsftpd/login

 

7.创建user_conf目录,在目录中创建文本文件,名称为用户名,内容为:

vi devicelog

local_root=/home/ftpadmin/devicelog        #当前虚拟用户家目录

local_max_rate=10485760   #传输速度上限

cmds_allowed=FEAT,REST,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RMD,SIZE,STOR,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST  #允许的指令,上传,不能删除,移动重命名

 

8.在配置文件/etc/vsftpd/vsftpd.conf中添加以下内容:

user_config_dir=/etc/vsftpd/user_conf

 

9.将devicelog用户加入chroot_list

 

10.将主目录权限修改为770,便于多用户使用和管理此目录

 

11.重启ftp服务

service vsftpd restart

 

附:

组合范例

完全权限:

cmds_allowed=ABOR,CWD,LIST,DELE,RMD,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RETR,RNFR,RNTO,SIZE,STOR,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST

 

仅上传权限:

cmds_allowed=FEAT,REST,CWD,LIST,MDTM,MKD,NLST,PASS,PASV,PORT,PWD,QUIT,RMD,SIZE,STOR,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST

 

权限项详情:

commoncommands 常用命令:

# ABOR - abort a filetransfer 取消文件传输

# CWD - change workingdirectory 更改目录

# DELE - delete a remotefile 删除文件

# LIST - list remotefiles 列出目录

# MDTM - return themodification time of a file 返回文件的更新时间

# MKD - make a remotedirectory 新建文件夹

# NLST -name list of remote directory 文件夹重命名

# PASS -send password 发送密码

# PASV -enter passive mode 进入被动模式

# PORT - open a data port打开一个传输端口

# PWD - print workingdirectory 显示当前工作目录

# QUIT - terminate theconnection 退出

# RETR - retrieve aremote file 下载文件

# RMD -remove a remote directory 删除文件夹

# RNFR -rename from 重命名

# RNTO -rename to 重命名

# SITE -site-specific commands 特定的命令

# SIZE - return the sizeof a file 返回文件大小

# STOR - store a file onthe remote host 上传文件

# TYPE -set transfer type 设置传输类型

# USER -send username 发送的用户名

 

# lesscommon commands 不常用命令:

# ACCT*- send account information 发送账号信息

# APPE -append to a remote file 追加文件

# CDUP -CWD to the parent of the current directory 进入上级目录

# HELP -return help on using the server 返回帮助信息

# MODE -set transfer mode 设置传输模式

# NOOP -do nothing 等待,此命令不产生什么实际动作,它仅使服务器返回OK。

# REIN*- reinitialize the connection 重新初始化连接

# STAT -return server status 返回服务器状态

# STOU -store a file uniquely 唯一地存储文件

# STRU -set file transfer structure 设置文件传输结构

# SYST -return system type 返回系统类型

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值