目录
一、vsftpd基本信息
二、vsftpd安装及启用,并允许匿名用户访问
1、 servic配置,在主机50上配置
2、 client(westosa100)测试命令
三、匿名用户访问控制
1、匿名用户登陆控制: anonymous_enable=YES|NO 上面二中演示过了
2、更改默认发布目录: anon_root=/westosdir
3、允许匿名用户上传文件: anon_upload_enable=YES|NO
4、允许匿名用户建立、删除目录:anon_mkdir_write_enable=YES|NO
5、允许匿名用户下载文件:anon_world_readable_only=NO( 匿名用户可以下载不能读的文件)
6、允许匿名用户删除,重命名:anon_other_write_enable=YES|NO
7、匿名用户上传文件权限设定:anon_umask=xxx
8、匿名用户上传文件的用户身份设定:chown_upload=YES chown_username=westos
9、登陆用户数量控制:max_clients=x
10、上传文件速率控制:anon_max_rate=xxxx
实验环境
- 关闭selinux
[root@westosa100 ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
[root@westosa100 ~]# reboot
- 关闭火墙 [root@westosa100 ~]# systemctl disable --now firewalld
- ip设置
- 软件仓库搭建
服务名称 : vsftpd.service配置目录 : / etc / vsftpd主配置文件 : / etc / vsftpd / vsftpd.conf默认发布目录 : / var / ftp报错信息 :550 ##程序本身拒绝553 ##文件系统权限限制500 ##权限过大530 ##认证失败
[root@westos_student50 Desktop]# vim /etc/sysconfig/selinux
[root@westos_student50 Desktop]# reboot
[root@westos_student50 Desktop]# dnf install vsftpd ####service
[root@westos_student50 Desktop]# dnf install lftp -y ####client上也需要安装
[root@westos_student50 Desktop]# systemctl enable --now vsftpd
[root@westos_student50 Desktop]# firewall-cmd --permanent --add-service=ftp
[root@westos_student50 Desktop]# firewall-cmd --reload
[root@westos_student50 Desktop]# lftp 172.25.254.50 -u westos
[root@westos_student50 Desktop]# vim /etc/vsftpd/vsftpd.conf ###配置允许匿名用户访问
anonymous_enable=YES
[root@westos_student50 Desktop]# systemctl restart vsftpd ###重启服务
[root@westos_student50 Desktop]# cd /var/ftp/
[root@westos_student50 Desktop]# ls
[root@westos_student50 Desktop]# touch westos{1..5}
[root@westos_student50 Desktop]# ls
lftp 172.25.254.50 ##当访问ftp服务时没有加入用户认证为匿名访问
lftp 172.25.254.50 -u westos ##本地用户访问
lftp 192.168.0.10 ##当访问ftp服务时没有加入用户认证为匿名访问
lftp 192.168.0.10 -u westos ##本地用户访问
anonymous_enable=YES|NO 上面二中演示过了
anon_root=/westosdir
[root@westos_student50 Desktop]# mkdir /westosdir
[root@westos_student50 Desktop]# vim /etc/vsftpd/vsftpd.conf
12 anon_root=/westosdir ####12是行号
[root@westos_student50 Desktop]# systemctl restart vsftpd.service
[root@westos_student50 Desktop]# touch /westosdir/westosfile{1..5}
[root@westos_student50 Desktop]# lftp 172.25.254.50
lftp 172.25.254.50:~> ls
-rw-r--r-- 1 0 0 0 Nov 23 13:54 westosfile1
-rw-r--r-- 1 0 0 0 Nov 23 13:54 westosfile2
-rw-r--r-- 1 0 0 0 Nov 23 13:54 westosfile3
-rw-r--r-- 1 0 0 0 Nov 23 13:54 westosfile4
-rw-r--r-- 1 0 0 0 Nov 23 13:54 westosfile5
anon_upload_enable=YES|NO
[root@westos_student50 Desktop]# vim /etc/vsftpd/vsftpd.conf
30 anon_upload_enable=YES
[root@westos_student50 Desktop]# systemctl restart vsftpd.service
[root@westos_student50 Desktop]# chmod 755 /var/ftp/
[root@westos_student50 Desktop]# chmod 777 /var/ftp/pub
[root@westos_student50 Desktop]# lftp 172.25.254.50
lftp 172.25.254.50:/> cd /pub
cd ok, cwd=/pub
lftp 172.25.254.50:/pub> put /etc/passwd
2792 bytes transferred
anon_mkdir_write_enable=YES|NO
[root@westos_student50 Desktop]# vim /etc/vsftpd/vsftpd.conf
34 anon_mkdir_write_enable=YES
[root@westos_student50 Desktop]# systemctl restart vsftpd.service
anon_world_readable_only=NO
( 匿名用户可以下载不能读的文件)[root@westos_student50 Desktop]# vim /etc/vsftpd/vsftpd.conf
35 anon_world_readable_only=NO
[root@westos_student50 Desktop]# systemctl restart vsftpd.service
[root@westos_student50 Desktop]# lftp 172.25.254.50
lftp 172.25.254.50:~> cd /pub
cd ok, cwd=/pub
lftp 172.25.254.50:/pub> get passwd
2792 bytes transferred
anon_other_write_enable=YES|NO
[root@westos_student50 Desktop]# vim /etc/vsftpd/vsftpd.conf
31 anon_other_write_enable=YES
[root@westos_student50 Desktop]# systemctl restart vsftpd.service
[root@westos_student50 Desktop]# lftp 172.25.254.50
lftp 172.25.254.50:~> cd /pub
cd ok, cwd=/pub
lftp 172.25.254.50:/pub> ls
-rw------- 1 14 50 2792 Nov 23 14:14 passwd
drwx------ 2 14 50 6 Nov 23 14:22 test
lftp 172.25.254.50:/pub> mv passwd haha
rename successful
lftp 172.25.254.50:/pub> ls
-rw------- 1 14 50 2792 Nov 23 14:14 haha
drwx------ 2 14 50 6 Nov 23 14:22 test
lftp 172.25.254.50:/pub> rm -fr haha
rm ok, `haha' removed
lftp 172.25.254.50:/pub> ls
drwx------ 2 14 50 6 Nov 23 14:22 test
anon_umask=xxx
服务默认上传文件的权限为600,编写vsftp服务的配置文件,设定anon_umask=022,重启服务,访问ftp在pub/中上传文件/etc/passwd,可以看到文件权限为644(777-022-111),权限设定生效
[root@westos_student50 Desktop]# vim /etc/vsftpd/vsftpd.conf
36 anon_umask=022
[root@westos_student50 Desktop]# systemctl restart vsftpd.service
[root@westos_student50 Desktop]# lftp 172.25.254.50
lftp 172.25.254.50:~> cd pub/
cd ok, cwd=/pub
lftp 172.25.254.50:/pub> ls
drwx------ 2 14 50 6 Nov 23 14:22 test
lftp 172.25.254.50:/pub> put /etc/passwd
2792 bytes transferred
lftp 172.25.254.50:/pub> ls
-rw-r--r-- 1 14 50 2792 Nov 23 14:51 passwd
drwx------ 2 14 50 6 Nov 23 14:22 test
chown_upload=YES
chown_username=westos
[root@westos_student50 Desktop]# cd /var/ftp
[root@westos_student50 ftp]# ls
pub westos1 westos2 westos3 westos4 westos5
[root@westos_student50 ftp]# ls -ld pub/
drwxrwxrwx 3 root ftp 32 Nov 23 22:51 pub/
[root@westos_student50 ftp]# chmod 775 pub/
[root@westos_student50 ftp]# chgrp ftp pub/
[root@westos_student50 ftp]# ls -ld pub/
drwxrwxr-x 3 root ftp 32 Nov 23 22:51 pub/
[root@westos_student50 ftp]# vim /etc/vsftpd/vsftpd.conf
48 chown_uploads=YES
49 chown_username=westos
[root@westos_student50 ftp]# systemctl restart vsftpd.service
[root@westos_student50 ftp]# lftp 172.25.254.50
lftp 172.25.254.50:~> cd pub/
cd ok, cwd=/pub
lftp 172.25.254.50:/pub> ls
-rw-r--r-- 1 14 50 2792 Nov 23 14:51 passwd
drwx------ 2 14 50 6 Nov 23 14:22 test
lftp 172.25.254.50:/pub> put /etc/inittab
490 bytes transferred
lftp 172.25.254.50:/pub> ls
-rw------- 1 1000 50 490 Nov 24 03:21 inittab
-rw-r--r-- 1 14 50 2792 Nov 23 14:51 passwd
drwx------ 2 14 50 6 Nov 23 14:22 test
lftp 172.25.254.50:/pub> quit
[root@westos_student50 ftp]# id westos
uid=1000(westos) gid=1000(westos) groups=1000(westos)
[root@westos_student50 ftp]# vim /etc/vsftpd/vsftpd.conf
chown_uploads=YES
chown_username=westos
chown_upload_mode=0644
[root@westos_student50 ftp]# systemctl restart vsftpd.service
[root@westos_student50 ftp]# lftp 172.25.254.50
lftp 172.25.254.50:~> cd pub/
cd ok, cwd=/pub
lftp 172.25.254.50:/pub> put /etc/adjtime
18 bytes transferred
lftp 172.25.254.50:/pub> ls
-rw-r--r-- 1 1000 50 18 Nov 24 03:27 adjtime
-rw------- 1 1000 50 490 Nov 24 03:21 inittab
-rw-r--r-- 1 14 50 2792 Nov 23 14:51 passwd
drwx------ 2 14 50 6 Nov 23 14:22 test
max_clients=x
[root@westos_student50 ftp]# vim /etc/vsftpd/vsftpd.conf
53 max_clients=2
[root@westos_student50 ftp]# systemctl restart vsftpd.service
anon_max_rate=xxxx
所有命令
[root@westos_student50 ftp]# dd if=/dev/zero of=/tmp/bigfile bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 2.93426 s, 357 MB/s
[root@westos_student50 ftp]# lftp 172.25.254.50
lftp 172.25.254.50:~> cd pub/
cd ok, cwd=/pub
lftp 172.25.254.50:/pub> put /tmp/bigfile
1048576000 bytes transferred in 4 seconds (241.24 MiB/s)
lftp 172.25.254.50:/pub> quit
[root@westos_student50 ftp]# vim /etc/vsftpd/vsftpd.conf
anon_max_rate=102400
[root@westos_student50 ftp]# systemctl restart vsftpd.service
[root@westos_student50 ftp]# lftp 172.25.254.50
lftp 172.25.254.50:~> cd pub/
cd ok, cwd=/pub
lftp 172.25.254.50:/pub> rm -fr bigfile ###先删除之前下载的文件
rm ok, `bigfile' removed
lftp 172.25.254.50:/pub> put /tmp/bigfile #####再次下载
`/tmp/bigfile' at 45666038 (4%) 106.6K/s eta:2h40m [Sending data]