分类: 系统运维
2008-01-11 19:21:37
心血来潮,架设了一个ftp
server方便我的windows访问Linux上的资源。
ftp服务器软件采用安全性较高的vsftp(very secure ftp)。以下讲解如何配置vsftp以使得
达到访问控制的。
首先系统中必须安装vsftpd这个软件,网络上很多的rpm以及deb格式的免费软件可以自由使用
下面我们看看如何配置它。
核心配置文件:/etc/vsftpd/vsftpd.conf(每次修改该文件必须重启vsftpd才能生效)
其他配置文件:ftpusers user_list
下面着重讲解/etc/vsftpd/vsftpd.conf如何配置。
一个实际的配置文件内容如下:
大部分需要我们做的事情是修改或是添加一部分内容,我通过注释的形式讲解哪些是比较关键的配置,哪些是对一般应用有帮助。
# Example config file /etc/vsftpd/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.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO#如果你希望搭建一个匿名ftp那么这个选项必须开启YES
#
# Uncomment this to allow local users to log in.
local_enable=YES#local的意思是本地实际存在的用户,YES是说你允许本地的用户从别的地方以ftp的形式访问
#
# 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#这个是用户的umask
#
# 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#允许匿名用户upload文件
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=YES#允许匿名用户写,前提是“write_enable=YES “
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=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
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 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().
#chroot_list_enable=YES#比较重要可以chroot的行为
# (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#不重要
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES#重要也是可以设置成listen_address=
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd whith two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd#pam(pluggble authentication module)是一种系统服务验证的手段
userlist_enable=NO#很重要可以控制指定用户的访问权限(控制这个文件中的user的权限/etc/vsftpd/user_list)
tcp_wrappers=YES
# Added by
#listen_port=6006#更改默认的控制端口(21)数据端口是(20)
ftp_username=ftpuser#虚拟用户的名字,也就是说local并不存在这样一个用户,仅仅为ftp访问而存在后面会讲述怎么创建这种用户
#same priority as local users else same as anonymous
virtual_use_local_privs=YES#对安全控制很重要的选项
#Force the local users in their homes
chroot_local_user=YES
#xferglog_enable=YES
#chroot_secure_dir=/
上面是配置文件的讲解,下面针对具体的应用,列举几个例子。
设置匿名ftp。这个没有难度将anonymous_enable=YES将vsftpd重新启用就行了
为了安全,其他的也要配置,可以自己查看man page
允许本地帐户通过ftp访问自己的资源。
local_enable=YES
同样重启服务就可以
添加虚拟用户。这个比较重要,但是很简单。
在terminal下 运行如下命令即可:
#adduser
–g ftp –s /sbin/nologin account_for_ftp_name
这样就生成一个名字为account_for_ftp_name的虚拟帐户,在windows端使用它就可以正常登陆了。
暂时写到这里,下星期继续补充。
chinaunix网友2009-05-22 09:41:49
哇哦不错,不过不够详细。 看看这个 http://jxbing.cn/upload/200812010102313074.pdf
chinaunix网友2008-08-04 19:53:22
SAP99,支持下,也欢迎访问我的博客, SAP资料多多 http://sap99.cublog.cn 完整的一个SAP培训系列教材,中文E文的都有部份, 一共679多M,涉及SAP的多个模块 地址:http://www.sap99.com/Soft/VIP/200807/64.html