Linux 搭建FTP的vsftpd.conf文件配置详解

1.默认配置
根据默认配置给出中文注释

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

2.过滤配置文件多余注释
过滤掉那些注释,以便我们日后修改配置,大家可以删除vsftpd.conf内容,拷贝以下:

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

chown_uploads=YES

chown_username=whoever

xferlog_file=/var/log/vsftpd.log

xferlog_std_format=YES

idle_session_timeout=600

data_connection_timeout=120

nopriv_user=ftpsecure

async_abor_enable=YES

ascii_upload_enable=YES

ascii_download_enable=YES

ftpd_banner=Welcome to blah FTP service.

deny_email_enable=YES

banned_email_file=/etc/vsftpd/banned_emails

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list

ls_recurse_enable=YES

listen=YES

listen_ipv6=YES

pam_service_name=vsftpd

userlist_enable=YES

tcp_wrappers=YES

3.vsftpd.conf支持特性详解
#################用户选项###############

接受匿名用户
anonymous_enable=YES

匿名用户login时不询问口令

no_anon_password=YES

匿名用户主目录

anon_root=(none)

接受本地用户

local_enable=YES

本地用户主目录

local_root=(none)

如果匿名用户需要密码,那么使用banned_email_file里面的电子邮件地址的用户不能登录

deny_email_enable=YES

仅在没有pam验证版本时有用,是否检查用户有一个有效的shell来登录

check_shell=YES

若启用此选项,userlist_deny选项才被启动

userlist_enable=YES

若为YES,则userlist_file中的用户将不能登录,为NO则只有userlist_file的用户可以登录

userlist_deny=NO

如果和chroot_local_user一起开启,那么用户锁定的目录来自/etc/passwd每个用户指定的目录(这个不是很清楚,很哪位熟悉的指点一下)

passwd_chroot_enable=NO

定义匿名登入的使用者名称。默认值为ftp。

ftp_username=FTP

#################用户权限控制###############

可以上传(全局控制).

write_enable=YES

本地用户上传文件的umask

local_umask=022

上传文件的权限配合umask使用

file_open_mode=0666

匿名用户可以上传

anon_upload_enable=NO

匿名用户可以建目录

anon_mkdir_write_enable=NO

匿名用户其它的写权利(更改权限?)
anon_other_write_enable=NO

如果设为YES,匿名登入者会被允许下载可阅读的档案。默认值为YES。
anon_world_readable_only=YES

如果开启,那么所有非匿名登陆的用户名都会被切换成guest_username指定的用户名

guest_enable=NO

所有匿名上传的文件的所属用户将会被更改成chown_username
chown_uploads=YES

匿名上传文件所属用户名
chown_username=lightwiter

如果启动这项功能,则所有列在chroot_list_file之中的使用者不能更改根目录

chroot_list_enable=YES

允许使用\”async ABOR\”命令,一般不用,容易出问题

async_abor_enable=YES

管控是否可用ASCII 模式上传。默认值为NO。
ascii_upload_enable=YES

管控是否可用ASCII 模式下载。默认值为NO。

ascii_download_enable=YES

这个选项必须指定一个空的数据夹且任何登入者都不能有写入的权限,当vsftpd 不需要file system 的权限时,就会将使用者限制在此数据夹中。默认值为/usr/share/empty

secure_chroot_dir=/usr/share/empty

###################超时设置##################

空闲连接超时

idle_session_timeout=600

数据传输超时

data_connection_timeout=120

PAVS请求超时

ACCEPT_TIMEOUT=60

PROT模式连接超时

connect_timeout=60

################服务器功能选项###############

开启日记功能

xferlog_enable=YES

使用标准格式

xferlog_std_format=YES

当xferlog_std_format关闭且本选项开启时,记录所有ftp请求和回复,当调试比较有用.

log_ftp_protocol=NO

允许使用pasv模式

pasv_enable=YES

关闭安全检查,小心呀.

pasv_promiscuous+NO

允许使用port模式

port_enable=YES

关闭安全检查

prot_promiscuous

开启tcp_wrappers支持

tcp_wrappers=YES

定义PAM 所使用的名称,预设为vsftpd。

pam_service_name=vsftpd

当服务器运行于最底层时使用的用户名

nopriv_user=nobody

使vsftpd在pasv命令回复时跳转到指定的IP地址.(服务器联接跳转?)

pasv_address=(none)

#################服务器性能选项##############

是否能使用ls -R命令以防止浪费大量的服务器资源

ls_recurse_enable=YES

是否使用单进程模式

one_process_model

绑定到listen_port指定的端口,既然都绑定了也就是每时都开着的,就是那个什么standalone模式

listen=YES

当使用者登入后使用ls -al 之类的指令查询该档案的管理权时,预设会出现拥有者的UID,而不是该档案拥有者的名称。若是希望出现拥有者的名称,则将此功能开启。

text_userdb_names=NO

显示目录清单时是用本地时间还是GMT时间,可以通过mdtm命令来达到一样的效果

use_localtime=NO

测试平台优化

use_sendfile=YES

################信息类设置################

login时显示欢迎信息.如果设置了banner_file则此设置无效

ftpd_banner=欢迎来到湖南三辰Fake-Ta FTP 网站.

允许为目录配置显示信息,显示每个目录下面的message_file文件的内容

dirmessage_enable=YES

显示会话状态信息,关!

setproctitle_enable=YES

############## 文件定义 ##################

定义不能更改用户主目录的文件

chroot_list_file=/etc/vsftpd/vsftpd.chroot_list

定义限制/允许用户登录的文件

userlist_file=/etc/vsftpd/vsftpd.user_list

定义登录信息文件的位置

banner_file=/etc/vsftpd/banner

禁止使用的匿名用户登陆时作为密码的电子邮件地址

banned_email_file=/etc/vsftpd.banned_emails

日志文件位置

xferlog_file=/var/log/vsftpd.log

目录信息文件

message_file=.message

############## 目录定义 #################

定义用户配置文件的目录

user_config_dir=/etc/vsftpd/userconf

定义本地用户登陆的根目录,注意定义根目录可以是相对路径也可以是绝对路径.相对路径是针对用户家目录来说的.

local_root=webdisk #此项设置每个用户登陆后其根目录为/home/username/webdisk

匿名用户登陆后的根目录

anon_root=/var/ftp

#############用户连接选项#################

可接受的最大client数目

max_clients=100

每个ip的最大client数目

max_per_ip=5

使用标准的20端口来连接ftp

connect_from_port_20=YES

绑定到某个IP,其它IP不能访问

listen_address=192.168.0.2

绑定到某个端口

listen_port=2121

数据传输端口

ftp_data_port=2020

pasv连接模式时可以使用port 范围的上界,0 表示任意。默认值为0。

pasv_max_port=0

pasv连接模式时可以使用port 范围的下界,0 表示任意。默认值为0。

pasv_min_port=0

##############数据传输选项#################

匿名用户的传输比率(b/s)

anon_max_rate=51200

本地用户的传输比率(b/s)

local_max_rate=5120000

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,753评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,668评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 166,090评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,010评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,054评论 6 395
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,806评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,484评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,380评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,873评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,021评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,158评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,838评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,499评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,044评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,159评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,449评论 3 374
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,136评论 2 356

推荐阅读更多精彩内容