1 安装vsftpd

yum -y install vsftpd

yum -y install ftp  客户端

2 编辑配置文件

vim /etc/vsftpd/vsftpd.conf

anonymous_enable=YES
anon_upload_enable=YES
anon_other_write_enable=YES
anon_mkdir_write_enable=YES
匿名用户不提示密码
no_anon_password=YES
设置匿名用户为ftp,默认为anonymous
ftp_username=ftp
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

 3 设置目录权限

匿名用户的默认上传路径为:/var/ftp/pub/

[root@localhost ftp]# pwd
/var/ftp
[root@localhost ftp]# ll
total 0
drwxr-xr-x. 3 root root 19 Nov 18 23:34 pub

 在pub目录下新建一个目录other,用于上传文件

[root@localhost pub]# pwd
/var/ftp/pub
[root@localhost pub]# ll
total 0
drwxrwxrwx. 2 root root 6 Nov 19 01:59 other

 4 开启服务

 systemctl start vsftpd

5 验证匿名用户上传文件

[root@localhost pub]# ftp localhost
Trying ::1...
Connected to localhost (::1).
220 (vsFTPd 3.0.2)
Name (localhost:root): ftp
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||31691|).
150 Here comes the directory listing.
drwxr-xr-x    3 0        0              19 Nov 19 07:34 pub
drwxrwxrwx    2 0        0               6 Nov 19 01:54 write
226 Directory send OK.
ftp> cd pub/other
250 Directory successfully changed.
ftp> put /tmp/123.txt aa.txt  将123.txt 文件上传到other目录下,并重命名为aa.txt
local: /tmp/123.txt remote: aa.txt
229 Entering Extended Passive Mode (|||7371|).
150 Ok to send data.
226 Transfer complete.
4 bytes sent in 3.6e-05 secs (111.11 Kbytes/sec)
ftp>