前言

对机器配置的要求:
需要一台电脑做服务器,配置并不需要太高,主流配置甚至以下的机器都可以,因为我们用linux系统下的开源软件vsftpd做服务器端。甚至并不需要显示器,在配置系统时可临时借用其他机器的显示器,以后的管理工作可通过SSH来进行。但网络是必须的,硬盘也还是大一点的好。因此,当你有一台淘汰下来的闲置的低配机器时,可考虑发挥它的余热,用来做ftp,分享一些电影、音乐、软件等资源。

对系统的要求:
为了安装的方便,最好已经安装了一下几个工具:lftp,vim,emacs,wget。

本文配置的ftp实现的功能有:
可以匿名访问,可以在特定的目录匿名上传,匿名用户没有删除权力。可以许多的本地用户访问,对其独有文件夹具有完全的权限,这许多的用户分成几个组,设有组内共享文件夹,组间不能访问。

安装vsftpd

$ sudo apt-get install vsftpd

配置vsftpd

配置/etc/vsftpd.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# 服务器以standalong模式运行,这样可以进行下面的控制
listen=YES
# 接受匿名用户
anonymous_enable=YES
# 匿名用户login时不询问口令
no_anon_password=YES
# 接受本地用户
local_enable=YES
# 可以上传(全局控制).若想要匿名用户也可上传则需要设置anon_upload_enable=YES, 
# 若想要匿名用户可以建立目录则需要设置anon_mkdir_write_enable=YES.这里禁止匿
# 名用户上传,所以不设置这两项.
write_enable=YES
# 本地用户上传文件的umask
local_umask=022
# 如果设为YES,匿名登入者会被允许上传目录的权限,当然,匿名使用者必须要有对上
# 层目录的写入权。
anon_upload_enable=YES
# 定义匿名登入的使用者名称。默认值为ftp
ftp_username=ftp
# 如果设为YES,匿名登入者会被允许新增目录,当然,匿名使用者必须要有对上层目录
# 的写入权。
anon_mkdir_write_enable=YES
# 为YES则进入目录时显示此目录下由message_file选项指定的文本文件
# (,默认为.message)的内容
dirmessage_enable=YES
# 本地用户login后所在目录,若没有设置此项,则本地用户login后将在他的home目录
# (/etc/passwd的第六个字段)中.匿名用户的对应选项是anon_root
# local_root=/home
anon_root=/home/ftp/
# 使用上传/下载日志,日志文件默认为/var/log/vsftpd.log,可以通过xferlog_file
# 选项修改
xferlog_enable=YES
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
# 日志使用标准xferlog格式
xferlog_std_format=YES
# You may change the default value for timing out a data connection.
data_connection_timeout=120
# 关闭本地用户chroot()
chroot_local_user=NO
# 设置为yes则下面的控制有效。
# 开启要设置chroot()用户项.
chroot_list_enable=YES
# (default follows)
# 指定要设置chroot()的特定用户文件
chroot_list_file=/etc/vsftpd.chroot_list
# 若设置为YES则记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)
# 中的用户无法login,并且将检察下面的userlist_deny选项
userlist_enable=YES
# 若为NO,则仅接受记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)
# 中的用户的login请求.若为YES则不接受这些用户的请求.
userlist_deny=NO
# 注意!!!vsftpd还要检察/etc/vsftpd.ftpusers文件,记录在这个文件中的用户将
# 无法login!!
# 匿名用户的传输比率(b/s)
anon_max_rate=512000
# 本地用户的传输比率(b/s)
local_max_rate=1024000
# 可接受的最大client数目
max_clients=100
# 每个ip的最大client数目
max_per_ip=5
# This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem access.
secure_chroot_dir=/var/run/vsftpd
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
 
tcp_wrappers=YES
 
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
# 每一个联机,都能以独立的process 来呈现.
setproctitle_enable=YES
# 若是启动,所有匿名上传数据的拥有者将被更换为chown_username当中所设定的使用
# 者。这样的选项对于安全及管理,是很有用的。
chown_uploads=YES
# 这里可以定义当匿名登入者上传档案时,该档案的拥有者将被置换的使用者名称。预
# 设值为root。
chown_username=root
Tags: ,.
你好!除了代码,此处没有多少原创之物,皆为本人搜集、整理、总结之记录与心得,欢迎转载分享!转载时请尽量注明出处,将不胜感激。祝你健康、快乐!
Home

RFC: Request For Comments. Orz..

Be the first to comment on this entry.

Name(required)
Mail (required),(will not be published)
Website(recommended)