FTP限制用户访问其他目录

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

前提:

开始:

添加用户:

# 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相关教程见以下内容

猜你喜欢

转载自www.linuxidc.com/Linux/2017-11/148312.htm
今日推荐