FTP:安装包是vsftpd-version (very secure FTP daemon)

,用于文件传输。一般用于局域网。

服务器IP:192.168.1.31

客户端IP:192.168.1.32

用户:1、匿名用户ftp

           2、普通用户a1,a2

           3、虚拟用户

 

vsftpd的配置_default

关闭selinux后,普通用户就可以登录了。

 

vsftpd的配置_服务器_02

普通用户登录后,只是在自己的家目录下,可以随意到系统的其他目录下。

 

以下是配置文档配置说明

[root@www vsftpd]# pwd

/etc/vsftpd

[root@www vsftpd]# vim 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=YES  //匿名用户登录开启,ftp用户可以登录

#

# 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  //上传文件权限,只对本地用户生效


例如:

客户端验证
[root@localhost ~]# lftp -l a1@192.168.1.31   lftp登录

lftp a1@192.168.1.31:~> put /etc/inittab 

884 bytes transferred     

 

 

#

# 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  //是否允许匿名用户有上传权限

 

例如:

服务器端:

[root@www ftp]# ls

inittab  pub  upload

[root@www ftp]# setfacl -m u:ftp:rwx upload/

lftp 192.168.1.31:/upload> put /etc/inittab 

884 bytes transferred

 

lftp 192.168.1.31:/upload> help  //帮助命令

    !<shell-command>                     (commands)

    alias [<name> [<value>]]             bookmark [SUBCMD]

    cache [SUBCMD]                       cat [-b] <files>

    cd <rdir>                            chmod [OPTS] mode file...

    close [-a]                           [re]cls [opts] [path/][pattern]

    debug [<level>|off] [-o <file>]      du [options] <dirs>

    exit [<code>|bg]                     get [OPTS] <rfile> [-o <lfile>]

    glob [OPTS] <cmd> <args>             help [<cmd>]

    history -w file|-r file|-c|-l [cnt]  jobs [-v]

    kill all|<job_no>                    lcd <ldir>

    lftp [OPTS] <site>                   ls [<args>]

    mget [OPTS] <files>                  mirror [OPTS] [remote [local]]

    mkdir [-p] <dirs>                    module name [args]

    more <files>                         mput [OPTS] <files>

    mrm <files>                          mv <file1> <file2>

    [re]nlist [<args>]                   open [OPTS] <site>

    pget [OPTS] <rfile> [-o <lfile>]     put [OPTS] <lfile> [-o <rfile>]

    pwd [-p]                             queue [OPTS] [<cmd>]

    quote <cmd>                          repeat [OPTS] [delay] [command]

    rm [-r] [-f] <files>                 rmdir [-f] <dirs>

    scache [<session_no>]                set [OPT] [<var> [<val>]]

    site <site_cmd>                      source <file>

    torrent [-O <dir>] <file>            user <user|URL> [<pass>]

    version                              wait [<jobno>]

    zcat <files>                         zmore <files>

 

#

# Uncomment this if you want the anonymous FTP user to be able to create

# new directories.

anon_mkdir_write_enable=YES  //创建目录的权限


anon_other_write_enable=YES  //其他权限


例如:lftp 192.168.1.31:/upload> rmdir test/


#

# Activate directory messages - messages given to remote users when they

# go into a certain directory.

dirmessage_enable=YES //每切换一个目录,出现欢迎信息

例如:

[root@www upload]# cat .message 

-----welcom to upload

--thith you ----

 

 

ftp> cd upload

250------welcom to upload

250---thith you ----

250 Directory successfully changed.  //显示了编辑的文件信息。


#

# The target log file can be vsftpd_log_file or xferlog_file.

# This depends on setting xferlog_std_format parameter

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

属主和属组的改变

 

 

#

# The name of log file when xferlog_enable=YES and xferlog_std_format=YES

# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log

xferlog_file=/var/log/vsftpd.log  //传输日志文件在哪里,


例如,查看日志文件

[root@www log]# cat vsftpd.log 

Thu Jun 19 22:01:16 2014 1 192.168.1.32 0 /fstab b _ i a lftp@ ftp 0 * i

Thu Jun 19 22:01:30 2014 1 192.168.1.32 899 /upload/fstab b _ i a lftp@ ftp 0 * c




#

# Switches between logging into vsftpd_log_file and xferlog_file files.

# NO writes to vsftpd_log_file, YES to xferlog_file

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_local_user=YES  //锁定用户于家目录中


chroot: 禁锢用户于其家目录中,实现方式有两种:

1、禁锢所有用户:

chroot_local_user=YES

2、禁锢指定用户,黑名单 

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list 

3、不禁锢指定用户,白名单

chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot_list 

 

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  //递归显示文件,危险

#

# 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

#

# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6

# sockets, you must run two copies of vsftpd with two configuration files.

# Make sure, that one of the listen options is commented !!

#listen_ipv6=YES


pam_service_name=vsftpd     //pam文件,

这个文件,

[root@www vsftpd]# vim /etc/pam.d/vsftpd 


userlist_enable=YES

ftpusers  user_list  这两个文件是限制用户登录的

userlist_deny=NO //当有这项的时候,user_list中的用户,就可以登录ftp

user_list:ftp用户白名单和黑名单:

1、白名单:

userlist_enable=YES

userlist_deny=NO

2、黑名单:默认即是

userlist_enable=YES

userlist_deny=YES

 

tcp_wrappers=YES


传输速率限定,默认单位为字节:

anon_max_rate=100000

local_max_rate=2000000