1、VSFTPD配置
anonymous_enable=YES local_enable=YES write_enable=YES local_umask=022 anon_upload_enable=YES anon_mkdir_write_enable=YES dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_std_format=YES listen=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES pasv_min_port=6000 pasv_max_port=6010 anon_umask=022 anon_other_write_enable=YES
注:未进行用户家目录锁定,只是简单配置
新建匿名用户上传文件目录upload
cd /var/ftp mkdir upload chmod 777 upload
2、Shell脚本实现文件上传
#!/bin/sh FILE=hosts ftp -n 192.168.203.129<<EOF user "ftp" " " binary cd upload lcd /etc/ put $FILE bye EOF
注:ftp为匿名用户,密码为空。binary为以二进制进行传输
#!/bin/sh FILE=hosts ftp -n 192.168.203.129<<EOF user root Abc123 binary cd /var/ftp/upload/ lcd /etc/ put $FILE bye EOF
注:如需root用户上传文件,将ftpusers,user_list两个文件中的root注释