Linux vfpd锁定用户目录

在linux ftp配置中,为了防止用户cd 到其他目录,需要锁定用户的根目录。

Step1:修改配置文件

[root@ess ~]# vi /etc/vsftpd/vsftpd.conf 

#chroot_local_user=YES
chroot_list_enable=YES                           //取消该行注释
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list     //取消该行注释,并且创建/etc/vsftpd/chroot_list

allow_writeable_chroot=YES                 //加入该行

Step2:将需要锁定目录的用户加入列表

[root@ess ~]# vi /etc/vsftpd/chroot_list

tom

Step3:重启vsftpd服务

[root@ess ~]# systemctl restart vsftpd.service

Step4:测试

C:>ftp 192.168.1.10
连接到 192.168.1.10。
220 (vsFTPd 3.0.2)
用户(192.168.1.10:(none)): tom
331 Please specify the password.
密码:
230 Login successful.
ftp> dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxrwxr-x 3 1000 1000 3 Jan 31 02:49 2019
drwxr-xr-x 2 1000 1000 2 Jan 31 03:02 perl5
226 Directory send OK.
ftp: 收到 128 字节,用时 0.00秒 128.00千字节/秒。
ftp> cd /
250 Directory successfully changed.
ftp> pwd
257 "/"

原文地址:https://www.cnblogs.com/networking/p/10341215.html