ftp 配置

ftp用户:
    系统用户
    匿名用户---->系统用户 
    虚拟用户---->系统用户

ftp用户的默认访问目录:
    匿名用户访问目录:/var/ftp
    系统用户的访问目录:用户的家目录


安全通信方式
    ftps: ftp+ssl/tls
    sftp: OpenSSH,SubSystem,sftp(SSH)


1 安装软件

[root@CnBJYwz01QNmoSmokepingL01 ~]# yum -y install vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * epel: mirrors.aliyun.com
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:2.2.2-21.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================
 Package                                 Arch                                    Version                                          Repository                             Size
==============================================================================================================================================================================
Installing:
 vsftpd                                  x86_64                                  2.2.2-21.el6                                     base                                  155 k

Transaction Summary
==============================================================================================================================================================================
Install       1 Package(s)

Total download size: 155 k
Installed size: 340 k
Downloading Packages:
vsftpd-2.2.2-21.el6.x86_64.rpm                                                                                                                         | 155 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : vsftpd-2.2.2-21.el6.x86_64                                                                                                                                 1/1 
  Verifying  : vsftpd-2.2.2-21.el6.x86_64                                                                                                                                 1/1 

Installed:
  vsftpd.x86_64 0:2.2.2-21.el6                                                                                                                                                

Complete!

[root@CnBJYwz01QNmoSmokepingL01 ~]# rpm -ql vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-2.2.2
.......
/var/ftp             //ftp服务的根目录
/var/ftp/pub

2 启动服务

[root@CnBJYwz01QNmoSmokepingL01 ~]# /etc/init.d/vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]
[root@CnBJYwz01QNmoSmokepingL01 ~]# chkconfig vsftpd on
[root@CnBJYwz01QNmoSmokepingL01 ~]#

3 测试登陆

匿名登陆ftp服务器
localhost:~ ray$ ftp 192.168.2.141
Connected to 192.168.2.141.
220 (vsFTPd 2.2.2)
Name (192.168.2.141:ray): anonymous
331 Please specify the password.
Password: 
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 
ftp> help
Commands may be abbreviated.  Commands are:

!        features    mls        prompt        site
$        fget        mlsd        proxy        size
account        form        mlst        put        sndbuf
append        ftp        mode        pwd        status
ascii        gate        modtime        quit        struct
bell        get        more        quote        sunique
binary        glob        mput        rate        system
bye        hash        mreget        rcvbuf        tenex
case        help        msend        recv        throttle
cd        idle        newer        reget        trace
cdup        image        nlist        remopts        type
chmod        lcd        nmap        rename        umask
close        less        ntrans        reset        unset
cr        lpage        open        restart        usage
debug        lpwd        page        rhelp        user
delete        ls        passive        rmdir        verbose
dir        macdef        pdir        rstatus        xferbuf
disconnect    mdelete        pls        runique        ?
edit        mdir        pmlsd        send
epsv4        mget        preserve    sendport
exit        mkdir        progress    set
ftp> 

系统用户登陆
[localhost:~ ray$ ftp 192.168.2.142
Connected to 192.168.2.142.
220 (vsFTPd 2.2.2)
Name (192.168.2.142:ray): ray
331 Please specify the password.
Password: 
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 
ftp> 
ftp> ls
229 Entering Extended Passive Mode (|||59706|).
150 Here comes the directory listing.
226 Directory send OK.
ftp> 
ftp> pwd
Remote directory: /home/ray
ftp>


4 常用配置文件参数

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES  #是否允许匿名用户登陆

# 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      #是否允许上传文件

anon_upload_enable=YES  #是否允许匿名用户上传文件,打开上传权限。注意:最终文件能否上传成功,取决于文件系统权限和文件共享权限

anon_mkdir_write_enable=YES  #是否允许匿名用户创建目录
anon_other_write_enable=YES  #是否允许匿名用户其他写动作,如:删除和修改

# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES        #当用进入目录,是否显示欢迎信息

# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES            #是否打开传输日志,记录上传下载的操作命令

# 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/xferlog       #指定传输日志的路径

# 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 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          #超时时间,数据连接


# 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                #是否将所有用户限制在主目录,YES为启用 NO禁用.(该项默认值是NO,即在安装vsftpd后不做配置的话,ftp用户是可以向上切换到要目录之外的)
#chroot_list_enable=YES               #是否允许启用限制用户名单
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list      #禁锢用户列表,文件需要主动创建


# 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                            #是否为独立守护进程


userlist_enable=YES                   #是否启用/etc/vsftpd/user_list名单
userlist_deny=YES                     #yes表示/etc/vsftpd/user_list为黑名单,no为白名单,

#If vsftpd is in standalone mode, this is the maximum number of clients which may be connected. Any additional clients connecting will get an error message.  The value 0 switches off the limit.
max_clients                   #限制最大客户端数量

#If vsftpd is in standalone mode, this is the maximum number of clients which may be connected from the same source internet address. A  client  will get an error message if they go over this limit. The value 0 switches off the limit.
max_per_ip                    #限制相同IP的连接客户端数量


对于ftp用户访问ftp服务时应该对其chroot
          禁锢用户于其家目录中
               chroot_local_user={Yes|No}

               chroot_list_enable={YES|NO}
               chroot_list_file=/etc/vsftpd/chroot_list
                    每行一个用户

     匿名用户的配置:
          anonymous_enable=YES
          anon_upload_enable=YES
          anon_other_write_enable=YES
          anon_mkdir_write_enable=YES

          注意:启用写入功能时,ftp用户对相应的本地文件系统也有相应的写入权限;
               生效的权限取决于文件系统权限和服务权限的交集;

     欢迎信息的定义:
          banner_file=/path/to/some_banner_file
          ftp_banner=some string
          dirmessage_enable=yes
               在某ftp可访问的目录下创建.messages文件

     vsftp控制登录用户的机制:
          /etc/vsftpd/ftpusers中的用户都不允许使用ftp服务, 这是在/etc/pam.d/vsftpd中定义;

          user_list配置文件有两种用法:
               黑名单:
                    userlist_enable=YES
                    userlist_deny=YES
               白名单
                    userlist_enable=YES
                    userlist_deny=NO

     连接限制:
          max_clients: 最大并发连接数
          max_per_ip: 每IP可同时发起并发请求

     传输速率:
          anon_max_rate: 匿名用户的最大传输速率,单位是“字节/秒”;
          local_max_rate: 本地用户……………………

     上传文件的umask:
          anno_umask: 匿名用户上传文件的umask;
          local_umask:

     修改匿名用户上传文件的属主和属组:
          chown_uploads=YES
          chown_username=someuser

     虚拟用户:
          所有的虚拟用户会映射会一个系统用户,访问时的文件目录是为此系统用户的家目录;

          虚拟用户:
               hash编码的文件:
                    奇数行为用户名,偶数行为密码

               关系型数据库:
                    pam-mysql实现认证

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28572479/viewspace-2131982/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28572479/viewspace-2131982/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值