阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

FTP限制用户访问其他目录

200次阅读
没有评论

共计 1560 个字符,预计需要花费 4 分钟才能阅读完成。

前记:自己做了个虚拟机,想用 ftp 连接,然后又不想让 ftp 访问到其他的目录。

前提:

系统为 Ubuntu 16.04 服务器版,已安装 vsftpd(安装方法:sudo apt-get install vsftpd),ftp 连接程序 -FileZilla。

开始:

添加用户:

# useradd -d /home/test -g test -s /sbin/nologin test

修改用户默认目录。(我的用户为 test)
两种方法:
1.usermod -d /home/test test
2.vim /etc/passwd 修改默认目录

限制访问其他目录:

# vim /etc/vsftpd.conf(也有其他版本说在 /etc/vsftpd/vsftpd.conf,未验证)

修改:

chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list #(与 conf 文件在同一目录下)
allow_writeable_chroot=YES # 这句可解决 "500 OOPS: vsftpd: refusing to run with writable root inside chroot()" 问题

然后:
vim /etc/vsftpd.chroot_list
添加想要限制的用户名,我的用户为 test。

test

一个用户一行

然后重启服务

# service vsftpd restart

补充:如果 ftp 连接上,但是不能显示正确目录,可能是权限问题,给 test 用户添加目录的读写权限就行了

OK :)

PS: 这三条控制 ftp 可写文件

FTP 限制用户访问其他目录

更多 Vsftpd 相关教程见以下内容

Linux CentOS 6.5 下搭建 vsftpd ftp 服务器  http://www.linuxidc.com/Linux/2016-07/133319.htm

CentOS 安装 vsftpd-3.0.2 及安全配置  http://www.linuxidc.com/Linux/2016-12/138040.htm

openSUSE 13.2/13.1 下安装配置 FTP 服务器 vsftpd  http://www.linuxidc.com/Linux/2014-12/110070.htm

CentOS7 基于虚拟用户的 vsftpd  http://www.linuxidc.com/Linux/2016-11/137150.htm

Ubuntu 14.04 配置 vsftpd 实现 FTP 服务器 – 通过 FTP 连接 AWS  http://www.linuxidc.com/Linux/2016-08/133933.htm

FTP 协议详解与 vsftpd 在 Linux 上的安装配置 http://www.linuxidc.com/Linux/2016-09/134831.htm

CentOS 6.7 安装 vsftpd 服务器  http://www.linuxidc.com/Linux/2017-04/142612.htm

CentOS 7.3 安装配置 Vsftpd 文件服务器  http://www.linuxidc.com/Linux/2017-06/144886.htm

Vsftpd3.0–FTP 服务器搭建之本地用户篇  http://www.linuxidc.com/Linux/2017-04/142699.htm

CentOS7 基于虚拟用户的 vsftpd  http://www.linuxidc.com/Linux/2016-11/137150.htm

Ubuntu 16.04 下 vsftpd 安装配置实例  http://www.linuxidc.com/Linux/2017-06/144807.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-11/148312.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计1560字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中