zoukankan      html  css  js  c++  java
  • centos6.5 vsftpd的搭建

    1.安装

    (1) rpm -qa | grep vsftpd查看是否已经安装
    (2) yum -y install vsftpd
    (3) 默认配置文件在/etc/vsftpd/vsftpd.conf
    

    2.创建虚拟用户

    (1) 创建ftp文件夹  mkdir ftpfile 例如 /ftpfile
    (2) 添加匿名用户 : useradd ftpuser -d /ftpfile -s /sbin/nologin  (用户没有登陆linux的权限)
    (3) 修改ftpfile权限:  chown -R  ftpuser.ftpuser /ftpfile
    (4) 重设ftpuser密码: passwd ftpuser
    
    

    3.配置

    (1) cd /etc/vsftpd
    (2) sudo vim chroot_list (以前没有)
    (3) 把刚才新增的虚拟用户添加到此配置文件中,后续要引用
    (4) sudo vim /etc/selinux/config,修改SELINUX=disabled  
    注意:如果一会验证时遇到550拒绝访问执行: sudo setsebool -P ftp_home_dir 1
    (5) 配置/etc/vsftpd/vsftpd.conf
    

    4.vsftp配置参数介绍

    本项目要用到的配置项:
    1)local_root=/ftpfile(当本地用户登入时,将被更换到定义的目录下,默认值为各用户的家目录) 
    2)anon_root=/ftpfile(使用匿名登入时,所登入的目录) 
    3)use_localtime=YES(默认是GMT时间,改成使用本机系统时间)
    4)anonymous_enable=NO(不允许匿名用户登录)
    5)local_enable=YES(允许本地用户登录)
    6)write_enable=YES(本地用户可以在自己家目录中进行读写操作)
    7)local_umask=022(本地用户新增档案时的umask值)
    8)dirmessage_enable=YES(如果启动这个选项,那么使用者第一次进入一个目录时,会检查该目录下是否有.message这个档案,如果有,则会出现此档案的内容,通常这个档案会放置欢迎话语,或是对该目录的说明。默认值为开启)
    9)xferlog_enable=YES(是否启用上传/下载日志记录。如果启用,则上传与下载的信息将被完整纪录在xferlog_file 所定义的档案中。预设为开启。)
    10)connect_from_port_20=YES(指定FTP使用20端口进行数据传输,默认值为YES)
    11)xferlog_std_format=YES(如果启用,则日志文件将会写成xferlog的标准格式)
    12)ftpd_banner=Welcome to mmall FTP Server(这里用来定义欢迎话语的字符串)
    13)chroot_local_user=NO(用于指定用户列表文件中的用户是否允许切换到上级目录)
    14)chroot_list_enable=YES(设置是否启用chroot_list_file配置项指定的用户列表文件)
    15)chroot_list_file=/etc/vsftpd/chroot_list(用于指定用户列表文件)
    16)listen=YES(设置vsftpd服务器是否以standalone模式运行,以standalone模式运行是一种较好的方式,此时listen必须设置为YES,此为默认值。建议不要更改,有很多与服务器运行相关的配置命令,需要在此模式下才有效,若设置为NO,则vsftpd不是以独立的服务运行,要受到xinetd服务的管控,功能上会受到限制)
    17)pam_service_name=vsftpd(虚拟用户使用PAM认证方式,这里是设置PAM使用的名称,默认即可,与/etc/pam.d/vsftpd对应) userlist_enable=YES(是否启用vsftpd.user_list文件,黑名单,白名单都可以
    18)pasv_min_port=61001(被动模式使用端口范围最小值)
    19)pasv_max_port=62000(被动模式使用端口范围最大值)
    20)pasv_enable=YES(pasv_enable=YES/NO(YES)
    若设置为YES,则使用PASV工作模式;若设置为NO,则使用PORT模式。默认值为YES,即使用PASV工作模式。
       FTP协议有两种工作方式:PORT方式和PASV方式,中文意思为主动式和被动式。
       一、PORT(主动)方式的连接过程是:客户端向服务器的FTP端口(默认是21)发送连接请求,服务器接受连接,建立一条命令链路。 
      当需要传送数据时,客户端在命令链路上用 PORT命令告诉服务器:“我打开了****端口,你过来连接我”。于是服务器从20端口向客户端的****端口发送连接请求,建立一条数据链路来传送数据。
       二、PASV(被动)方式的连接过程是:客户端向服务器的FTP端口(默认是21)发送连接请求,服务器接受连接,建立一条命令链路。 
      当需要传送数据时,服务器在命令链路上用 PASV命令告诉客户端:“我打开了****端口,你过来连接我”。于是客户端向服务器的****端口发送连接请求,建立一条数据链路来传送数据。 
      从上面可以看出,两种方式的命令链路连接方法是一样的,而数据链路的建立方法就完全不同。而FTP的复杂性就在于此。
    )
    

    5.防火墙的配置

    vim /etc/sysconfig/iptables
    
    添加下面的配置
    #vsftpd
    -A INPUT  -p TCP --dport 61001:62000 -j ACCEPT
    -A OUTPUT  -p TCP --sport 61001:62000 -j ACCEPT
    -A INPUT -p TCP --dport 20 -j ACCEPT
    -A OUTPUT  -p TCP --sport 20 -j ACCEPT
    -A INPUT  -p TCP --dport 21 -j ACCEPT
    -A OUTPUT -p TCP --sport 21 -j ACCEPT
    
    重启防火墙:
    sudo service iptables restart
    
    

    6.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
    #
    # 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
    #
    # 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/xferlog
    #
    # 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.
    
    
    local_root=/home/ftpfile
    anon_root=/home/ftpfile
    use_localtime=yes
    
    
    #
    # 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_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
    userlist_enable=YES
    tcp_wrappers=YES
    
    
    pasv_min_port=61001
    pasv_max_port=62000
    
    

    7.浏览器登陆

    ftp://121.42.165.99/
    
  • 相关阅读:
    获取父页面标签对象,获取当前标签div高度
    响应回车事件
    解决checkbox的attr(checked)一直为undefined问题
    返回键 隐藏、、收起键盘textView|textField
    ios9 之后,Xcode7不推荐使用UIAlertView,改用UIAlertController+UIAlertAction(按钮)
    判断是否是 首次 进入app,,以及Xcode7之后前导页的设置
    根据 字数 确定 UI控件高度
    对于限制UITextView输入的字符数
    block 反向传值回调
    NSUserDefault的使用
  • 原文地址:https://www.cnblogs.com/snakejia/p/8207172.html
Copyright © 2011-2022 走看看