分类: LINUX
2008-12-11 16:52:23
A. Installing FTP server
#yum install vsftpd
#rpm -qa|grep -i vsftpd
#rpm -ql vsftpd
/etc/logrotate.d/vsftpd.log
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz
/var/ftp
/var/ftp/pub
B. Allow anonymous upload files
Task: allow anonymous upload file to incoming/, but could NOT download or list files from the directory.
#mkdir -p /var/ftp/incoming
#chown root.ftp /var/ftp/incoming
#chmod 730 /var/ftp/incoming
#ls -ld /var/ftp/incoming/
drwx-wx--- 2 root ftp 4096 Nov 1 03:34 /var/ftp/incoming/
Note: this results that ftp group users can ONLY upload(write) to the incoming/ folder, but could NOT list the contents of this directory or even download from it.
#vi /etc/vsftpd/vsftpd.conf
anonymous_enable=YES # By default, YES
anon_upload_enable=YES # Allowanonymous to upload files (by default NO)
chown_uploads=YES # Allowed to change owner of the uploaded files from "ftp" or "anonymous" to other users
chown_username=daemon # Change owner of the uploaded file to "daemon"
anon_umask=077 # i.e. the uploaded files with permission of 600 ( rw-------); in other means, anonymous user can NOT upload the same file twice
#service vsftpd restart
C. Testing
On FTP server:
#touch /var/ftp/incoming/server.download-incoming
#touch /var/ftp/pub/server.download-pub
On FTP client:
#touch client.upload
#ftp 192.168.75.10
Name:ftp (or anonymous)
Password: (empty)
ftp>pwd
257 "/"
* Change-rooted directory: /var/ftp
ftp>ls
drwx-wx--- 2 0 50 4096 Dec 10 05:06 incoming
drwxr-xr-x 2 0 0 4096 Dec 10 05:09 pub
ftp>cd incoming
ftp>pwd
257 "/incoming"
ftp>ls
150 Here comes the directory listing.
226 Transfer done (but failed to open directory).
* Could NOT list contents of this folder.
ftp>put client.upload
150 Ok to send data.
226 File receive OK.
* Upload successfully to incoming/.
ftp>put client.upload
553 Could not create file.
* Could NOT upload the same file twice in incoming/.
ftp>get server.download-incoming
ftp>get client.upload
550 Failed to open file.
* Could NOT download files from incoming/, even the files uploaded by the anonymous user itself.
ftp>cd ..
ftp>cd pub
ftp>pwd
257 "/pub"
ftp>ls
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 0 Dec 10 05:19 server.download-pub
226 Directory send OK.
* Can list contents of pub/
ftp>put client.upload
553 Could not create file.
* Could NOT upload file to pub/
ftp>get server.download-pub
226 File send OK.
* Can download file from pub/