vsftpd.conf参数配置解析(ftp配置、ftp参数)

167 篇文章 11 订阅
文章介绍了Ubuntu20.04中vsftpd配置文件的关键参数,包括启用FTP写入、用户列表、权限设置、chroot限制、被动模式以及日志记录等,强调了安全性和性能优化的设置。通过修改配置,可以实现对FTP服务的精细控制,例如限制用户访问、启用被动模式FTP等。
摘要由CSDN通过智能技术生成

我ubuntu20.04默认安装的是:vsftpd_3.0.3-12_amd64.deb(ubuntu16.04安装的也是相同版本)

在这里插入图片描述

初始vsftdp.conf

# 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=NO
#
# 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=YES
#
# 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
#
# 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=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
#
# 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_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (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
# (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
#
# 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
#
# 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

翻译后

# 示例配置文件 /etc/vsftpd.conf
#
# 默认编译设置相当谨慎。这个示例文件
# 放松了一些限制,使ftp守护进程更易于使用。
# 请参阅vsftpd.conf.5以获取所有编译的默认值。
#
# 请阅读:这个示例文件不是vsftpd选项的详尽列表。
# 请阅读vsftpd.conf.5手册页,以全面了解vsftpd的功能。
#
#
# 独立运行?vsftpd可以从inetd或作为独立运行
# 守护进程从initscript启动。
listen=NO
#
# 此指令启用IPv6套接字上的侦听。默认情况下,侦听
# 在IPv6“任何”地址(::)上将接受来自IPv6和IPv4客户端的连接。它不必在*上侦听
# IPv4和IPv6套接字。如果您想要这样做(可能是因为您想要侦听特定的
# 地址),那么您必须运行两个vsftpd副本,每个副本都有两个配置
# 文件。
listen_ipv6=YES
#
# 允许匿名FTP?(默认情况下禁用)。
anonymous_enable=NO
#
# 取消注释此选项以允许本地用户登录。
local_enable=YES
#
# 取消注释此选项以启用任何形式的FTP写入命令。
#write_enable=YES
#
# 本地用户的默认umask为077。您可能希望将其更改为022,
# 如果您的用户期望(022由大多数其他ftpd使用)
#local_umask=022
#
# 取消注释此选项以允许匿名FTP用户上传文件。这只有
# 如果上面的全局写入启用已激活才会生效。此外,您将
# 显然需要创建一个FTP用户可写的目录。
#anon_upload_enable=YES
#
# 如果要使匿名FTP用户能够创建新目录,请取消注释此选项。
#anon_mkdir_write_enable=YES
#
# 激活目录消息-当他们进入某个目录时向远程用户发送的消息。
dirmessage_enable=YES
#
# 如果启用,vsftpd将在本地时区中显示带有时间的目录列表
# 在GMT中显示默认值。由
# MDTM FTP命令返回的时间也受此影响
# 选项。
use_localtime=YES
#
# 激活上传/下载日志记录。
xferlog_enable=YES
#
# 确保PORT传输连接起源于端口20(ftp-data)。
connect_from_port_20=YES
#
# 如果您愿意,可以安排上传的匿名文件由不同的用户拥有。注意!使用“root”上传文件不是
# 推荐!
#chown_uploads=YES
#chown_username=whoever
#
# 如果您愿意,可以更改日志文件的默认位置。
#xferlog_file=/var/log/vsftpd.log
#
# 如果您愿意,可以将日志文件设置为标准ftpd xferlog格式。
# 请注意,在这种情况下,默认日志文件位置为/var/log/xferlog。
#xferlog_std_format=YES
#
# 您可以更改空闲会话超时的默认值。
#idle_session_timeout=600
#
# 您可以更改数据连接超时的默认值。
#data_connection_timeout=120
#
# 建议您在系统上定义一个唯一的用户,该用户
# ftp服务器可以使用作为完全隔离和无特权用户。
#nopriv_user=ftpsecure
#
# 启用此选项,服务器将识别异步 ABOR 请求。不建议使用此选项(代码较为复杂),但不启用此选项可能会使旧的 FTP 客户端混淆。
#async_abor_enable=YES
#
# 默认情况下,服务器会假装允许 ASCII 模式,但实际上会忽略该请求。打开以下选项,使服务器在 ASCII 模式下实际执行文件的 ASCII 编码。
#请注意,在某些 FTP 服务器上,ASCII 支持允许通过 ASCII 模式下的“SIZE /big/file”命令进行拒绝服务(DoS)攻击。vsftpd 预测到了这种攻击,并始终是安全的,报告原始文件的大小。
# ASCII 编码是协议的一个可怕的特性。
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# 您可以完全自定义登录横幅字符串:
#ftpd_banner=欢迎使用 blah FTP 服务。
#
# 您可以指定一个禁止匿名电子邮件地址的文件。显然,这对于打击某些 DoS 攻击很有用。
#deny_email_enable=YES
#(默认值如下)
#banned_email_file=/etc/vsftpd.banned_emails
#
# 您可以将本地用户限制在其主目录中。在使用 chroot_local_user 或 chroot_list_enable 之前,请参阅 FAQ 中可能存在的风险。
#chroot_local_user=YES
#
# 您可以指定一个显式的本地用户列表,以将其 chroot() 到其主目录中。如果 chroot_local_user 为 YES,则此列表将成为不 chroot() 的用户列表。
#(警告!chroot 可能非常危险。如果使用 chroot,请确保用户没有写入 chroot 中的顶级目录的权限)
#chroot_local_user=YES
#chroot_list_enable=YES
#(默认值如下)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# 您可以激活内置 ls 的“-R”选项。默认情况下,此选项已禁用,以避免远程用户能够在大型站点上引起过多的 I/O。但是,一些破损的 FTP 客户端(如“ncftp”和“mirror”)假定存在“-R”选项,因此有充分的理由启用它。
#ls_recurse_enable=YES
#
# 自定义
#
# 默认情况下,vsftpd 的某些设置不适合文件系统布局。
#
# 此选项应为一个空目录的名称。此外,该目录不应由 ftp 用户可写。在某些 vsftpd 不需要文件系统访问的时候,该目录用作安全的 chroot() 狱。
secure_chroot_dir=/var/run/vsftpd/empty
# (在vsftpd.conf配置文件中,secure_chroot_dir=/var/run/vsftpd/empty表示在使用chroot_local_user选项时,指定一个安全的chroot目录。这个目录是一个空目录,只包含必要的系统文件和目录,而不包含任何用户数据或配置文件。这样做可以防止用户通过FTP访问系统中的其他文件和目录,从而提高系统的安全性。当用户使用FTP登录时,如果chroot_local_user选项被启用,那么用户将被限制在其主目录中。如果没有指定secure_chroot_dir,则用户可以通过FTP访问系统中的其他文件和目录。但是,如果指定了secure_chroot_dir,则用户将被限制在/var/run/vsftpd/empty目录中,无法访问其他目录。这个目录是一个安全的chroot目录,只包含必要的系统文件和目录,可以保护系统的安全性。)
#
# 此字符串是 vsftpd 将使用的 PAM 服务的名称。
pam_service_name=vsftpd
# (在vsftpd.conf配置文件中,pam_service_name=vsftpd表示使用PAM(Pluggable Authentication Modules)进行用户身份验证时,使用的PAM服务名称为“vsftpd”。PAM是一种标准化的身份验证机制,可以让系统管理员使用不同的身份验证方法来控制用户访问系统资源的权限。在vsftpd中,可以使用PAM来进行用户身份验证,以增强系统的安全性。当pam_service_name设置为vsftpd时,vsftpd将使用名为“vsftpd”的PAM服务来进行用户身份验证。管理员可以在PAM配置文件中定义这个服务,以指定使用哪种身份验证方法。例如,可以使用本地系统账户、LDAP、Kerberos等身份验证方法来验证用户身份。这样可以提高系统的安全性,并且可以根据需要灵活地配置身份验证方法。)
#
# 此选项指定用于 SSL 加密连接的 RSA 证书的位置。
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO

#
# 取消注释此选项以指示 vsftpd 使用 utf8 文件系统。
#utf8_filesystem=YES

需修改参数

write_enable=YES(启用任何形式的FTP写入命令)

在vsftpd配置文件中,write_enable=YES表示允许用户上传文件和创建新目录。如果设置为NO,则用户只能下载文件,不能上传或创建新目录。

userlist_file=/etc/vsftpd.user_list、userlist_enable=YES、userlist_deny=NO
  • userlist_file=/etc/vsftpd.user_list:指定用户列表文件的路径,该文件中列出的用户将被允许或拒绝访问FTP服务器。
  • userlist_enable=YES:启用用户列表功能,如果设置为NO,则用户列表文件将被忽略。
  • userlist_deny=NO:指定用户列表的行为,如果设置为YES,则只有在用户列表中列出的用户将被拒绝访问FTP服务器,如果设置为NO,则只有在用户列表中列出的用户将被允许访问FTP服务器。
local_umask=022(放开权限)

在vsftpd配置文件中,local_umask参数用于设置上传文件时的默认权限掩码。默认情况下,上传的文件权限为666,上传的目录权限为777。如果设置了local_umask参数,则会根据该参数设置的掩码来计算上传文件和目录的权限。

默认的umask为077表示新建文件的权限为600,新建目录的权限为700。umask是一种权限掩码,用于控制新建文件和目录的默认权限。它是一个三位八进制数,每一位表示一种权限(读、写、执行),0表示允许,1表示禁止。umask的值是从默认权限掩码中减去的,例如,umask为077,表示从默认权限掩码中减去777,得到的结果就是新建文件的权限为600,新建目录的权限为700。这样设置可以保证新建的文件和目录只有所有者有读写执行的权限,其他用户没有任何权限。

local_umask=022表示上传的文件权限为644,上传的目录权限为755。其中,022是一个三位八进制数,表示文件权限掩码。在Linux系统中,文件权限掩码用于控制文件的默认权限。它是一个三位八进制数,每一位表示一种权限(读、写、执行),0表示允许,1表示禁止。例如,022表示允许所有者和组成员读写,其他用户只能读取;755表示所有用户都可以读、写、执行。

chroot_local_user=YES(限定目录)(为了安全最好启用)

在vsftpd.conf配置文件中,chroot_local_user=YES表示将本地用户限制在其主目录中,防止他们访问系统中的其他文件和目录。这是一种安全措施,可以防止用户访问他们不应该访问的文件和目录,从而保护系统的安全性。当chroot_local_user设置为YES时,用户登录后将被限制在其主目录中,无法访问其他目录。

chroot的含义

chroot是"change root"的缩写,意为改变根目录。在Linux和Unix系统中,chroot是一种安全机制,可以将进程限制在指定的目录中,防止其访问系统中的其他文件和目录。通过chroot机制,可以创建一个虚拟的根目录,使进程只能访问该目录及其子目录,而不能访问系统中的其他文件和目录。
在FTP服务器中,chroot机制可以用于限制用户访问其主目录以外的文件和目录。通过将用户限制在其主目录中,可以防止他们访问系统中的其他文件和目录,从而提高系统的安全性。在vsftpd中,可以使用chroot_local_user选项将本地用户限制在其主目录中。

pasv_enable=YES、pasv_min_port=40000、pasv_max_port=50000(为了方便,最好打开?)

在vsftpd.conf配置文件中,pasv_enable=YES表示启用被动模式(Passive Mode)FTP。被动模式FTP是一种FTP数据传输模式,其中客户端使用随机端口连接FTP服务器的数据端口,而不是使用标准的FTP数据端口(端口20)。这种模式可以避免由于防火墙或NAT设备的限制而导致的FTP连接问题

需要设置pasv_enable=YES的情况包括:

  • 当FTP服务器位于防火墙或NAT设备后面时,需要启用被动模式FTP,以便客户端可以连接到FTP服务器的数据端口。

  • 当FTP服务器需要与其他系统进行数据交换时,需要启用被动模式FTP,以便其他系统可以连接到FTP服务器的数据端口。

需要注意的是,如果FTP服务器没有被防火墙或NAT设备限制,并且不需要与其他系统进行数据交换,则可以不启用被动模式FTP。在这种情况下,可以将pasv_enable设置为NO,以禁用被动模式FTP。

如果您需要启用被动模式FTP,则需要在vsftpd.conf配置文件中将pasv_enable设置为YES。如果未设置,则默认情况下被动模式FTP将被禁用。

如果您已经在vsftpd.conf配置文件中设置了pasv_enable=YES,则不需要再次添加。如果未设置,则可以添加该选项并将其设置为YES。例如:

pasv_enable=YES

请注意,如果您使用被动模式FTP,则还需要在防火墙中打开FTP数据端口范围(默认情况下是端口1024到65535)。否则,客户端可能无法连接到FTP服务器的数据端口。

allow_writeable_chroot=YES(允许用户在chroot环境中创建或修改文件)

在vsftpd.conf配置文件中,allow_writeable_chroot=YES表示允许在chroot环境中创建可写文件。chroot环境是一种安全机制,可以将用户限制在其主目录中,防止他们访问系统中的其他文件和目录。但是,如果不允许在chroot环境中创建可写文件,则用户将无法在其主目录中创建或修改文件,这可能会影响其正常使用FTP服务。

当allow_writeable_chroot设置为YES时,用户可以在chroot环境中创建可写文件。这意味着用户可以在其主目录中创建或修改文件,而不会受到chroot环境的限制。这可以提高FTP服务的灵活性和可用性。

需要注意的是,允许在chroot环境中创建可写文件可能会降低系统的安全性,因为用户可以在其主目录中创建或修改任何文件。因此,如果不需要在chroot环境中创建可写文件,则建议将allow_writeable_chroot设置为NO。

local_root=/home/ftp(指定限制根目录)(如果设置了chroot_local_user=YES,则没有必要)

如果设置了chroot_local_user=YES,那么FTP用户将被限制在其主目录中,无法访问系统中的其他文件和目录。在这种情况下,设置local_root=/home/ftp可能没有必要,因为FTP用户的根目录已经被限制为其主目录。

但是,如果需要将FTP用户的根目录设置为其他目录,可以设置local_root选项。例如,如果希望FTP用户的根目录为/var/ftp,可以将local_root设置为/var/ftp。在这种情况下,FTP用户将被限制在其主目录中,同时其根目录将设置为/var/ftp。

需要注意的是,如果不需要将FTP用户的根目录设置为其他目录,可以不设置local_root选项。在这种情况下,FTP用户的根目录将默认为其主目录。

listen=YES、listen_ipv6=NO、pasv_address=192.168.1.140(配置被动模式时,需要设置这个?)

对于Linux下的vsftpd,需添加:pasvaddress=公网IP。

或者关闭PASV模式的安全检查,即:pasv_promiscuous=YES,该检查确保数据连接和控制连接是来自同一个IP地址。小心打开此选项。此选项唯一合理的用法是存在于由安全隧道方案构成的组织中。默认值为NO。

● 注意:当使用pasv_address指定公网IP时,必须将监听的IP地址改为IPv4,即:listen=YES,否则vsftpd将返回错误的被动套接字,如:227 Entering Passive Mode (0,0,0,0,34,198).。而启用IPv4地址时则需要禁用IPv6地址的监听,因为两者互斥。

listen=YES        #指定被动模式时的公网IP地址时只能监听在IPv4地址
listen_ipv6=NO    #与listen冲突,默认监听IPv6地址,当监听在IPv4时IPv6必须禁用,否则vsftpd.service将无法启动
 
pasv_enable=YES
pasv_min_port=8900
pasv_max_port=8909
pasv_address=47.95.120.253       #指定被动模式时的公网IP地址
#pasv_addr_resolve=YES
#pasv_promiscuous=YES

参考文章:被动模式下FTP不能建立数据会话问题

这样设置,果真可以了:

在这里插入图片描述

xferlog_enable=YES、log_ftp_protocol=YES

xferlog_enable=YES是开启日志记录功能,由于生成日志还挺大,生产环境我们不开启;

log_ftp_protocol=YES是生成更加细节化的日志,同样,这个功能只建议在调试的时候开启。

关于listen=YES

具体来说,listen=NO表示vsftpd服务不以inetd方式运行,而是以独立守护进程的方式运行。如果将listen设置为YES,则表示vsftpd服务以inetd方式运行。

vsftpd可以以两种方式运行:独立守护进程和inetd方式

独立守护进程方式是指vsftpd作为一个独立的进程运行,它会一直在后台运行,等待客户端的连接请求。这种方式的优点是可以提高服务的响应速度和并发处理能力,因为它不需要每次都重新启动一个新的进程来处理客户端的请求。

inetd方式是指vsftpd作为inetd的一个服务运行,每当有客户端连接请求时,inetd会启动一个新的vsftpd进程来处理该请求。这种方式的优点是可以节省系统资源,因为它只在需要时才会启动一个新的进程来处理客户端请求。

总的来说,独立守护进程方式适合处理高并发的情况,而inetd方式适合处理低并发的情况。在实际应用中,可以根据具体的需求来选择合适的运行方式。

关于什么情况下要设置listen_ipv6=NO

listen_ipv6是vsftpd.conf配置文件中的一个选项,用于指定是否启用IPv6监听。如果将listen_ipv6设置为YES,则表示vsftpd服务将同时监听IPv4和IPv6地址;如果将其设置为NO,则表示vsftpd服务只监听IPv4地址。

在一些特定的情况下,可能需要将listen_ipv6设置为NO,例如:

  1. 系统不支持IPv6:如果系统不支持IPv6,那么启用IPv6监听是没有意义的,此时应该将listen_ipv6设置为NO

  2. 安全性考虑:如果系统管理员认为IPv6网络存在安全风险,或者不希望vsftpd服务被IPv6地址访问,那么可以将listen_ipv6设置为NO,只允许IPv4地址访问。

  3. 性能考虑:如果系统的网络环境中只有IPv4地址,那么启用IPv6监听会增加系统的负担,此时可以将listen_ipv6设置为NO,以提高系统的性能。

需要注意的是,如果系统同时支持IPv4和IPv6,而listen_ipv6被设置为NO,那么只有IPv4地址能够访问vsftpd服务,IPv6地址将无法访问。如果需要同时支持IPv4和IPv6,那么应该将listen_ipv6设置为YES

修改后vsftpd.conf(服务器容器方案1:支持passive被动模式)

# 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.

# origin
# listen=NO

# arnold modified 20230430
listen=YES

#
# 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.
# origin
# listen_ipv6=YES

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

#arnold modified 20230227
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

# arnold modified 20230428
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
#
# 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=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
#
# 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_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (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

# arnold modified 20230428
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
# (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
#
# 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
#
# 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

# arnold add 20230227
userlist_file=/etc/vsftpd.user_list
userlist_enable=YES
userlist_deny=NO

# arnold add 20230428
pasv_enable=YES
pasv_min_port=60001
pasv_max_port=60100

# arnold add 202300430 # for test
pasv_address=192.168.1.140
# pasv_addr_resolve=YES
# pasv_promiscuous=YES


# arnold add 20230428
allow_writeable_chroot=YES
  • 7
    点赞
  • 48
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
这段脚本的作用是修改/etc/vsftpd/vsftpd.conf文件中的FTP服务器配置。具体解释如下: ```shell if [ -f "/etc/vsftpd/vsftpd.conf" ];then if grep -q "ftpd_banner=Welcome to blah FTP service" /etc/vsftpd/vsftpd.conf then sed -i '/ftpd_banner=Welcome to blah FTP service/s/^#//' /etc/vsftpd/vsftpd.conf else echo 'ftpd_banner=Welcome to blah FTP service' >> /etc/vsftpd/vsftpd.conf fi if grep -q "chroot_local_user" /etc/vsftpd/vsftpd.conf then sed -i '/chroot_local_user=NO/s/^/#/' /etc/vsftpd/vsftpd.conf sed -i '/chroot_local_user=YES/s/^/#/' /etc/vsftpd/vsftpd.conf echo 'chroot_local_user=NO' >> /etc/vsftpd/vsftpd.conf else echo 'chroot_local_user=NO' >> /etc/vsftpd/vsftpd.conf fi if grep -q "chroot_list_enable" /etc/vsftpd/vsftpd.conf then sed -i '/chroot_list_enable=NO/s/^/#/' /etc/vsftpd/vsftpd.conf sed -i '/chroot_list_enable=YES/s/^/#/' /etc/vsftpd/vsftpd.conf echo 'chroot_list_enable=YES' >> /etc/vsftpd/vsftpd.conf else echo 'chroot_list_enable=YES' >> /etc/vsftpd/vsftpd.conf fi ``` - 首先检查/etc/vsftpd/vsftpd.conf文件是否存在。 - 如果存在,则执行以下操作: - 检查文件中是否存在"ftpd_banner=Welcome to blah FTP service"这一行。 - 如果存在,则使用sed命令将该行的行首的注释符号#去掉,即取消注释。 - 如果不存在,则在文件末尾添加一行"ftpd_banner=Welcome to blah FTP service",即设置FTP服务的欢迎信息。 - 检查文件中是否存在"chroot_local_user"这一行。 - 如果存在,则使用sed命令将"chroot_local_user=NO"和"chroot_local_user=YES"这两行的行首添加注释符号#,以禁用chroot_local_user功能。 - 然后在文件末尾添加一行"chroot_local_user=NO",即禁用本地用户的chroot特性。 - 如果不存在,则在文件末尾添加一行"chroot_local_user=NO",即禁用本地用户的chroot特性。 - 检查文件中是否存在"chroot_list_enable"这一行。 - 如果存在,则使用sed命令将"chroot_list_enable=NO"和"chroot_list_enable=YES"这两行的行首添加注释符号#,以禁用chroot_list_enable功能。 - 然后在文件末尾添加一行"chroot_list_enable=YES",即启用chroot列表。 - 如果不存在,则在文件末尾添加一行"chroot_list_enable=YES",即启用chroot列表。 这段脚本的目的是修改/etc/vsftpd/vsftpd.conf文件中的FTP服务器配置,包括设置FTP服务的欢迎信息、禁用本地用户的chroot特性和启用chroot列表。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dontla

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值