vsftpd.conf配置文件详解
- 0.vsftpd.conf配置文件
- 1.默认配置:
- 2.配置文件格式:
- 3.匿名用户(anonymous)设置
- 4.本地用户设置
- 5.欢迎语设置
- 6.控制用户是否允许切换到上级目录
- 7.数据传输模式设置
- 8.访问控制设置
- 9.访问速率设置
- 10.超时时间设置
- 11.日志文件设置
- 12.定义用户配置文件
- 13.FTP的工作方式与端口设置
- 14.与连接相关的设置
- 15.虚拟用户设置
- 16.其他设置
0.vsftpd.conf配置文件
路径 /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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157# Example config file /etc/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd’s # capabilities. # # # Run standalone? vsftpd can run either from an inetd or as a standalone # daemon started from an initscript. listen=YES (绑定到listen_port指定的端口,既然都绑定了也就是每时都开着的,就是standalone模式) # # This directive enables listening on IPv6 sockets. By default, listening # on the IPv6 “any” address (::) will accept connections from both IPv6 # and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6 # sockets. If you want that (perhaps because you want to listen on specific # addresses) then you must run two copies of vsftpd with two configuration # files. #listen_ipv6=no # # Allow anonymous FTP? (Disabled by default). anonymous_enable=NO (接受匿名用户,默认无密码请求) # # Uncomment this to allow local users to log in. local_enable=YES (接受本地用户) # # Uncomment this to enable any form of FTP write command. write_enable=YES (上传总开关) # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd’s) local_umask=022 (本地用户新增档案的权限) # # 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 (允许匿名用户上传文件) # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES (允许匿名用户创建新目录) # # Activate directory messages – messages given to remote users when they # go into a certain directory. dirmessage_enable=YES (允许为目录配置显示信息,显示每个目录下面的message_file文件的内容) # # If enabled, vsftpd will display directory listings with the time # in your local time zone. The default is to display GMT. The # times returned by the MDTM FTP command are also affected by this # option. use_localtime=YES # # Activate logging of uploads/downloads. xferlog_enable=YES (开启日记功能 ) # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=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) #chown_username=whoever (匿名上传文件所属用户名) # # You may override where the log file goes if you like. The default is shown # below. xferlog_file=/var/log/vsftpd.log (日志文件位置 ) # # If you want, you can have your log file in standard ftpd xferlog format. # Note that the default log file location is /var/log/xferlog in this case. #xferlog_std_format=YES (使用标准格式 ) # # You may change the default value for timing out an idle session. #idle_session_timeout=600 (空闲连接超时 ) # # You may change the default value for timing out a data connection. #data_connection_timeout=120 (数据传输超时 ) # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure (当服务器运行于最底层时使用的用户名) # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES (允许使用”async ABOR”命令,一般不用,容易出问题) # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command “SIZE /big/file” in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES (管控是否可用ASCII 模式上传。默认值为NO) #ascii_download_enable=YES (管控是否可用ASCII 模式下载。默认值为NO) # # You may fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. (login时显示欢迎信息.如果设置了banner_file则此设置无效) # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES (如果匿名用户需要密码,那么使用banned_email_file里面的电子邮件地址的用户不能登录) # (default follows) #banned_email_file=/etc/vsftpd.banned_emails (禁止使用匿名用户登陆时作为密码的电子邮件地址) # # You may restrict local users to their home directories. See the FAQ for # the possible risks in this before using chroot_local_user or # chroot_list_enable below. chroot_local_user=YES # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). # (Warning! chroot’ing can be very dangerous. If using chroot, make sure that # the user does not have write access to the top level directory within the # chroot) #chroot_local_user=YES #chroot_list_enable=YES (如果启动这项功能,则所有列在chroot_list_file中的使用者不能更改根目录) # (default follows) #chroot_list_file=/etc/vsftpd.chroot_list (定义不能更改用户主目录的文件) # # You may activate the “-R” option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as “ncftp” and “mirror” assume # the presence of the “-R” option, so there is a strong case for enabling it. #ls_recurse_enable=YES (是否能使用ls -R命令以防止浪费大量的服务器资源) # # Customization # # Some of vsftpd’s settings don’t fit the filesystem layout by # default. # # 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/empty # # This string is the name of the PAM service vsftpd will use. pam_service_name=vsftpd (定义PAM 所使用的名称,预设为vsftpd) # # This option specifies the location of the RSA certificate to use for SSL # encrypted connections. rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key ssl_enable=NO # # Uncomment this to indicate that vsftpd use a utf8 filesystem. #utf8_filesystem=YES
1.默认配置:
1>允许匿名用户和本地用户登陆。
1
2
3
4anonymous_enable=YES local_enable=YES
2>匿名用户使用的登陆名为ftp或anonymous,口令为空;匿名用户不能离开匿名用户家目录/var/ftp,且只能下载不能上传。
3>本地用户的登录名为本地用户名,口令为此本地用户的口令;本地用户可以在自 己家目录中进行读写操作;本地用户可以离开自家目录切换至有权限访问的其他目录,并在权限允许的情况下进行上传/下载。
1
2write_enable=YES
4>写在文件/etc/vsftpd.ftpusers中的本地用户禁止登陆。
2.配置文件格式:
vsftpd.conf 的内容非常单纯,每一行即为一项设定。若是空白行或是开头为#的一行,将会被忽略。内容的格式只有一种,如下所示
1
2option=value
要注意的是,等号两边不能加空白。
3.匿名用户(anonymous)设置
1
2anonymous_enable=YES/NO(YES)
控制是否允许匿名用户登入,YES 为允许匿名登入,NO 为不允许。默认值为YES。
1
2
3write_enable=YES/NO(YES)
是否允许登陆用户有写权限。属于全局设置,默认值为YES。
1
2
3no_anon_password=YES/NO(NO)
若是启动这项功能,则使用匿名登入时,不会询问密码。默认值为NO。
1
2ftp_username=ftp
定义匿名登入的使用者名称。默认值为ftp。
1
2anon_root=/var/ftp
使用匿名登入时,所登入的目录。默认值为/var/ftp。注意ftp目录不能是777的权限属性,即匿名用户的家目录不能有777的权限。
1
2anon_upload_enable=YES/NO(NO)
如果设为YES,则允许匿名登入者有上传文件(非目录)的权限,只有在write_enable=YES时,此项才有效。当然,匿名用户必须要有对上层目录的写入权。默认值为NO。
1
2anon_world_readable_only=YES/NO(YES)
如果设为YES,则允许匿名登入者下载可阅读的档案(可以下载到本机阅读,不能直接在FTP服务器中打开阅读)。默认值为YES。
1
2anon_mkdir_write_enable=YES/NO(NO)
如果设为YES,则允许匿名登入者有新增目录的权限,只有在write_enable=YES时,此项才有效。当然,匿名用户必须要有对上层目录的写入权。默认值为NO。
1
2anon_other_write_enable=YES/NO(NO)
如果设为YES,则允许匿名登入者更多于上传或者建立目录之外的权限,譬如删除或者重命名。(如果 anon_upload_enable=NO,则匿名用户不能上传文件,但可以删除或者重命名已经存在的文件;如果 anon_mkdir_write_enable=NO,则匿名用户不能上传或者新建文件夹,但可以删除或者重命名已经存在的文件夹。)默认值为NO。
1
2chown_uploads=YES/NO(NO)
设置是否改变匿名用户上传文件(非目录)的属主。默认值为NO。
1
2chown_username=username
设置匿名用户上传文件(非目录)的属主名。建议不要设置为root。
1
2anon_umask=077
设置匿名登入者新增或上传档案时的umask 值。默认值为077,则新建档案的对应权限为700。
1
2deny_email_enable=YES/NO(NO)
若是启动这项功能,则必须提供一个档案/etc/vsftpd/banner_emails,内容为email address。若是使用匿名登入,则会要求输入email address,若输入的email address 在此档案内,则不允许进入。默认值为NO。
1
2banned_email_file=/etc/vsftpd/banner_emails
此文件用来输入email address,只有在deny_email_enable=YES时,才会使用到此档案。若是使用匿名登入,则会要求输入email address,若输入的email address 在此档案内,则不允许进入。
4.本地用户设置
1
2local_enable=YES/NO(YES)
控制是否允许本地用户登入,YES 为允许本地用户登入,NO为不允许。默认值为YES。
1
2local_root=/home/username
当本地用户登入时,将被更换到定义的目录下。默认值为各用户的家目录。
1
2write_enable=YES/NO(YES)
是否允许登陆用户有写权限。属于全局设置,默认值为YES。
1
2local_umask=022
本地用户新增档案时的umask 值。默认值为077。
1
2file_open_mode=0755
本地用户上传档案后的档案权限,与chmod 所使用的数值相同。默认值为0666。
5.欢迎语设置
1
2dirmessage_enable=YES/NO(YES)
如果启动这个选项,那么使用者第一次进入一个目录时,会检查该目录下是否有.message这个档案,如果有,则会出现此档案的内容,通常这个档案会放置欢迎话语,或是对该目录的说明。默认值为开启。
1
2message_file=.message
设置目录消息文件,可将要显示的信息写入该文件。默认值为.message。
1
2banner_file=/etc/vsftpd/banner
当使用者登入时,会显示此设定所在的档案内容,通常为欢迎话语或是说明。默认值为无。如果欢迎信息较多,则使用该配置项。
1
2ftpd_banner=Welcome to BOB's FTP server
这里用来定义欢迎话语的字符串,banner_file是档案的形式,而ftpd_banner 则是字符串的形式。预设为无。
6.控制用户是否允许切换到上级目录
在默认配置下,本地用户登入FTP后可以使用cd命令切换到其他目录,这样会对系统带来安全隐患。可以通过以下三条配置文件来控制用户切换目录。
1
2chroot_list_enable=YES/NO(NO)
设置是否启用chroot_list_file配置项指定的用户列表文件。默认值为NO。
1
2chroot_list_file=/etc/vsftpd.chroot_list
用于指定用户列表文件,该文件用于控制哪些用户可以切换到用户家目录的上级目录。
1
2chroot_local_user=YES/NO(NO)
用于指定用户列表文件中的用户是否允许切换到上级目录。默认值为NO。
通过搭配能实现以下几种效果:
①当chroot_list_enable=YES,chroot_local_user=YES时,在/etc/vsftpd.chroot_list文件中列出的用户,可以切换到其他目录;未在文件中列出的用户,不能切换到其他目录。
②当chroot_list_enable=YES,chroot_local_user=NO时,在/etc/vsftpd.chroot_list文件中列出的用户,不能切换到其他目录;未在文件中列出的用户,可以切换到其他目录。
③当chroot_list_enable=NO,chroot_local_user=YES时,所有的用户均不能切换到其他目录。
④当chroot_list_enable=NO,chroot_local_user=NO时,所有的用户均可以切换到其他目录。
7.数据传输模式设置
FTP在传输数据时,可以使用二进制方式,也可以使用ASCII模式来上传或下载数据。
1
2ascii_upload_enable=YES/NO(NO)
设置是否启用ASCII 模式上传数据。默认值为NO。
1
2ascii_download_enable=YES/NO(NO)
设置是否启用ASCII 模式下载数据。默认值为NO。
8.访问控制设置
两种控制方式:一种控制主机访问,另一种控制用户访问。
①控制主机访问:
1
2tcp_wrappers=YES/NO(YES)
设置vsftpd是否与tcp wrapper相结合来进行主机的访问控制。默认值为YES。如果启用,则vsftpd服务器会检查/etc/hosts.allow 和/etc/hosts.deny 中的设置,来决定请求连接的主机,是否允许访问该FTP服务器。这两个文件可以起到简易的防火墙功能。
比如:若要仅允许192.168.0.1—192.168.0.254的用户可以连接FTP服务器,则在/etc/hosts.allow文件中添加以下内容:
1
2
3
4vsftpd:192.168.0. :allow all:all :deny
②控制用户访问:
对于用户的访问控制可以通过/etc目录下的vsftpd.user_list和ftpusers文件来实现。
1
2userlist_file=/etc/vsftpd.user_list
控制用户访问FTP的文件,里面写着用户名称。一个用户名称一行。
1
2userlist_enable=YES/NO(NO)
是否启用vsftpd.user_list文件。
1
2userlist_deny=YES/NO(YES)
决定vsftpd.user_list文件中的用户是否能够访问FTP服务器。若设置为YES,则vsftpd.user_list文件中的用户不允许访问FTP,若设置为NO,则只有vsftpd.user_list文件中的用户才能访问FTP。
/etc/vsftpd/ftpusers文件专门用于定义不允许访问FTP服务器的用户列表(注意: 如果userlist_enable=YES,userlist_deny=NO,此时如果在vsftpd.user_list和ftpusers中都有 某个用户时,那么这个用户是不能够访问FTP的,即ftpusers的优先级要高)。默认情况下vsftpd.user_list和ftpusers,这 两个文件已经预设置了一些不允许访问FTP服务器的系统内部账户。如果系统没有这两个文件,那么新建这两个文件,将用户添加进去即可。
9.访问速率设置
1
2anon_max_rate=0
设置匿名登入者使用的最大传输速度,单位为B/s,0 表示不限制速度。默认值为0。
1
2local_max_rate=0
本地用户使用的最大传输速度,单位为B/s,0 表示不限制速度。预设值为0。
10.超时时间设置
1
2accept_timeout=60
设置建立FTP连接的超时时间,单位为秒。默认值为60。
1
2connect_timeout=60
PORT 方式下建立数据连接的超时时间,单位为秒。默认值为60。
1
2data_connection_timeout=120
设置建立FTP数据连接的超时时间,单位为秒。默认值为120。
1
2idle_session_timeout=300
设置多长时间不对FTP服务器进行任何操作,则断开该FTP连接,单位为秒。默认值为300 。
11.日志文件设置
1
2xferlog_enable= YES/NO(YES)
是否启用上传/下载日志记录。如果启用,则上传与下载的信息将被完整纪录在xferlog_file 所定义的档案中。预设为开启。
1
2xferlog_file=/var/log/vsftpd.log
设置日志文件名和路径,默认值为/var/log/vsftpd.log。
1
2xferlog_std_format=YES/NO(NO)
如果启用,则日志文件将会写成xferlog的标准格式,如同wu-ftpd 一般。默认值为关闭。
1
2log_ftp_protocol=YES|NO(NO)
如果启用此选项,所有的FTP请求和响应都会被记录到日志中,默认日志文件在/var/log/vsftpd.log。启用此选项时,xferlog_std_format不能被激活。这个选项有助于调试。默认值为NO。
12.定义用户配置文件
在vsftpd中,可以通过定义用户配置文件来实现不同的用户使用不同的配置。
1
2user_config_dir=/etc/vsftpd/userconf
设置用户配置文件所在的目录。当设置了该配置项后,用户登陆服务器后,系统就会到/etc/vsftpd/userconf目录下,读取与当前用户名相同的文件,并根据文件中的配置命令,对当前用户进行更进一步的配置。
例如:定义user_config_dir=/etc/vsftpd/userconf,且主机上有使用 者 test1,test2,那么我们就在user_config_dir 的目录新增文件名为test1和test2两个文件。若是test1 登入,则会读取user_config_dir 下的test1 这个档案内的设定。默认值为无。利用用户配置文件,可以实现对不同用户进行访问速度的控制,在各用户配置文件中定义local_max_rate=XX, 即可。
13.FTP的工作方式与端口设置
FTP有两种工作方式:PORT FTP(主动模式)和PASV FTP(被动模式)
1
2listen_port=21
设置FTP服务器建立连接所监听的端口,默认值为21。
1
2connect_from_port_20=YES/NO
指定FTP使用20端口进行数据传输,默认值为YES。
1
2ftp_data_port=20
设置在PORT方式下,FTP数据连接使用的端口,默认值为20。
1
2pasv_enable=YES/NO(YES)
若设置为YES,则使用PASV工作模式;若设置为NO,则使用PORT模式。默认值为YES,即使用PASV工作模式。
1
2pasv_max_port=0
在PASV工作模式下,数据连接可以使用的端口范围的最大端口,0 表示任意端口。默认值为0。
1
2pasv_min_port=0
在PASV工作模式下,数据连接可以使用的端口范围的最小端口,0 表示任意端口。默认值为0。
14.与连接相关的设置
1
2listen=YES/NO(YES)
设置vsftpd服务器是否以standalone模式运行。以standalone模式运行是一种较好 的方式,此时listen必须设置为YES,此为默认值。建议不要更改,有很多与服务器运行相关的配置命令,需要在此模式下才有效。若设置为NO,则 vsftpd不是以独立的服务运行,要受到xinetd服务的管控,功能上会受到限制。
1
2max_clients=0
设置vsftpd允许的最大连接数,默认值为0,表示不受限制。若设置为100时,则同时允许有100个连接,超出的将被拒绝。只有在standalone模式运行才有效。
1
2max_per_ip=0
设置每个IP允许与FTP服务器同时建立连接的数目。默认值为0,表示不受限制。只有在standalone模式运行才有效。
1
2listen_address=IP地址
设置FTP服务器在指定的IP地址上侦听用户的FTP请求。若不设置,则对服务器绑定的所有IP地址进行侦听。只有在standalone模式运行才有效。
1
2setproctitle_enable=YES/NO(NO)
设置每个与FTP服务器的连接,是否以不同的进程表现出来。默认值为NO,此时使用ps aux |grep ftp只会有一个vsftpd的进程。若设置为YES,则每个连接都会有一个vsftpd的进程。
15.虚拟用户设置
虚拟用户使用PAM认证方式。
1
2pam_service_name=vsftpd
设置PAM使用的名称,默认值为/etc/pam.d/vsftpd。
1
2guest_enable= YES/NO(NO)
启用虚拟用户。默认值为NO。
1
2guest_username=ftp
这里用来映射虚拟用户。默认值为ftp。
1
2virtual_use_local_privs=YES/NO(NO)
当该参数激活(YES)时,虚拟用户使用与本地用户相同的权限。当此参数关闭(NO)时,虚拟用户使用与匿名用户相同的权限。默认情况下此参数是关闭的(NO)。
16.其他设置
1
2text_userdb_names= YES/NO(NO)
设置在执行ls –la之类的命令时,是显示UID、GID还是显示出具体的用户名和组名。默认值为NO,即以UID和GID方式显示。若希望显示用户名和组名,则设置为YES。
1
2ls_recurse_enable=YES/NO(NO)
若是启用此功能,则允许登入者使用ls –R(可以查看当前目录下子目录中的文件)这个指令。默认值为NO。
1
2hide_ids=YES/NO(NO)
如果启用此功能,所有档案的拥有者与群组都为ftp,也就是使用者登入使用ls -al之类的指令,所看到的档案拥有者跟群组均为ftp。默认值为关闭。
1
2download_enable=YES/NO(YES)
如果设置为NO,所有的文件都不能下载到本地,文件夹不受影响。默认值为YES。
最后
以上就是酷炫咖啡豆最近收集整理的关于vsftpd.conf配置文件详解0.vsftpd.conf配置文件1.默认配置:2.配置文件格式:3.匿名用户(anonymous)设置4.本地用户设置5.欢迎语设置6.控制用户是否允许切换到上级目录7.数据传输模式设置8.访问控制设置9.访问速率设置10.超时时间设置11.日志文件设置12.定义用户配置文件13.FTP的工作方式与端口设置14.与连接相关的设置15.虚拟用户设置16.其他设置的全部内容,更多相关vsftpd.conf配置文件详解0.vsftpd.conf配置文件1.默认配置:2.配置文件格式:3.匿名用户(anonymous)设置4.本地用户设置5.欢迎语设置6.控制用户是否允许切换到上级目录7.数据传输模式设置8.访问控制设置9.访问速率设置10.超时时间设置11.日志文件设置12.定义用户配置文件13.FTP内容请搜索靠谱客的其他文章。
发表评论 取消回复