文章目录
14.1 搭建只允许匿名用户访问文件共享服务器
修改配置文件并重启服务
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
local_enable=NO
anonymous_enable=YES
[root@localhost ~]# systemctl restart vsftpd
测试
[root@localhost ~]# ftp 192.168.217.154
Connected to 192.168.217.154 (192.168.217.154).
220 (vsFTPd 3.0.2)
Name (192.168.217.154:root): bob
530 This FTP server is anonymous only.
Login failed.
ftp>
测试浏览器访问ftp://192.168.217.154/
14.2 让本地用户登录时访问指定目录, 并不能跳出此目录
local_root=DIR
chroot_local_enable=yes
在/etc/vsftpd/vsftpd.conf文件写下
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
chroot_local_user=YES
local_root=/home/test
[root@localhost ~]# systemctl restart vsftpd
创建目录
[root@localhost ~]# mkdir /home/test
[root@localhost ~]# touch /home/test/123
登录
[root@localhost ~]# ftp 192.168.217.154
Connected to 192.168.217.154 (192.168.217.154).
220 (vsFTPd 3.0.2)
Name (192.168.217.154:root): bob
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/"
ftp> ls
227 Entering Passive Mode (192,168,217,154,59,29).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 0 May 16 03:27 123
226 Directory send OK.
ftp>
14.3 让匿名对某目录有权限上传文件
准备操作
[root@localhost ~]# mkdir /var/ftp/upload
[root@localhost ~]# chmod o+w /var/ftp/upload/
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
anon_mkdir_write_enable=YES
anon_upload_enable=YES
[root@localhost ~]# setenforce 0 #