今天看到了一个别人提的问题,如何在Linux上建立一个FTP服务器,可以用浏览器直接输入网址和文件夹来访问。
正好有时间,于是就把这个当成实验做了。
首先确认浏览器的访问方式,经过查询发现其实浏览器如果单纯用ftp://192.168.179.96这种方式是通过ftp的anonymous账号来浏览的(还有另一种更标准的浏览器的读取方式ftp://user:passwd@192.168.179.96/来进行浏览)。那主要的问题就是怎么给服务器端的vsftpd打开anonymous的访问权限。
但是我一直没用过这个功能,所以还挺头疼的。于是就开始搜索,发现这帮写文档的人还真是讨厌,每个都写的不全。于是只好自己做实验。
最终的配置是这么做的,只贴了anonymous的一部分。
# Anonymous users will only be allowed to download files which are
# world readable.
#
#anon_world_readable_only=YES
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#
anon_upload_enable=YES
#
# Default umask for anonymus users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#
#anon_umask=022
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#
anon_mkdir_write_enable=YES
#
# Uncomment this to enable anonymus FTP users to perform other write operations
# like deletion and renaming.
#
anon_other_write_enable=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#
chown_uploads=YES
chown_username=ftp,这里也可以设置成其它账号,区别的是新建的文件的权限。
#
# The maximum data transfer rate permitted, in bytes per second, for anonymous
# authenticated users. The default is 0 (unlimited).
#
#anon_max_rate=7200
这个是比较勤快的做法,因为我不但开启了网页下载权限还开了上传的权限。如果不要上传的话,只要开了anonymous就可以了。千万注意,一定不要开其余的配置,因为你一旦开了的话,就要定义好上传的各种权限,少配任何一个都会导致失败。
# Anonymus FTP user Settings
#
# Allow anonymous FTP?
#
anonymous_enable=YES
#
# Anonymous users will only be allowed to download files which are
# world readable.
#
anon_world_readable_only=YES
#
# Uncomment this to allow the anonymous FTP user to upload files. This only