前记:自己做了个虚拟机,想用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可写文件
更多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