centos6.8下配置vsftp

Posted cfas

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6.8下配置vsftp相关的知识,希望对你有一定的参考价值。

一、安装VSFTP

 

# yum -y install vsftpd

注意提升权限:

 

 

#su root


二、配置vsftpd.conf 文件

 

 

  1.  
    [[email protected] ~]# vi /etc/vsftpd/vsftpd.conf
  2.  
     
  3.  
    # Example config file /etc/vsftpd/vsftpd.conf
  4.  
    #
  5.  
    # The default compiled in settings are fairly paranoid. This sample file
  6.  
    # loosens things up a bit, to make the ftp daemon more usable.
  7.  
    # Please see vsftpd.conf.5 for all compiled in defaults.
  8.  
    #
  9.  
    # READ THIS: This example file is NOT an exhaustive list of vsftpd options.
  10.  
    # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd‘s
  11.  
    # capabilities.
  12.  
    #
  13.  
    # Allow anonymous FTP? (Beware - allowed by default if you comment this out).
  14.  
    #anonymous_enable=YES
  15.  
    #
  16.  
    # Uncomment this to allow local users to log in.
  17.  
    local_enable=YES
  18.  
    #
  19.  
    # Uncomment this to enable any form of FTP write command.
  20.  
    write_enable=YES
  21.  
    #
  22.  
    # Default umask for local users is 077. You may wish to change this to 022,
  23.  
    # if your users expect that (022 is used by most other ftpd‘s)
  24.  
    local_umask=022
  25.  
    #
  26.  
    # Uncomment this to allow the anonymous FTP user to upload files. This only
  27.  
    # has an effect if the above global write enable is activated. Also, you will
  28.  
    # obviously need to create a directory writable by the FTP user.
  29.  
    #anon_upload_enable=YES
  30.  
    #
  31.  
    # Uncomment this if you want the anonymous FTP user to be able to create
  32.  
    # new directories.
  33.  
    #anon_mkdir_write_enable=YES
  34.  
    #
  35.  
    # Activate directory messages - messages given to remote users when they
  36.  
    # go into a certain directory.
  37.  
    dirmessage_enable=YES
  38.  
    #
  39.  
    # The target log file can be vsftpd_log_file or xferlog_file.
  40.  
    # This depends on setting xferlog_std_format parameter
  41.  
    xferlog_enable=YES
  42.  
    #
  43.  
    # Make sure PORT transfer connections originate from port 20 (ftp-data).
  44.  
    connect_from_port_20=YES
  45.  
    #
  46.  
    # If you want, you can arrange for uploaded anonymous files to be owned by
  47.  
    # a different user. Note! Using "root" for uploaded files is not
  48.  
    # recommended!
  49.  
    #chown_uploads=YES
  50.  
     
  51.  
    #chown_username=whoever
  52.  
    #
  53.  
    # The name of log file when xferlog_enable=YES and xferlog_std_format=YES
  54.  
    # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
  55.  
    #xferlog_file=/var/log/xferlog
  56.  
    #
  57.  
    # Switches between logging into vsftpd_log_file and xferlog_file files.
  58.  
    # NO writes to vsftpd_log_file, YES to xferlog_file
  59.  
    xferlog_std_format=YES
  60.  
    #
  61.  
    # You may change the default value for timing out an idle session.
  62.  
    idle_session_timeout=600
  63.  
    #
  64.  
    # You may change the default value for timing out a data connection.
  65.  
    data_connection_timeout=120
  66.  
    # It is recommended that you define on your system a unique user which the
  67.  
    # ftp server can use as a totally isolated and unprivileged user.
  68.  
    #nopriv_user=ftpsecure
  69.  
    #
  70.  
    # Enable this and the server will recognise asynchronous ABOR requests. Not
  71.  
    # recommended for security (the code is non-trivial). Not enabling it,
  72.  
    # however, may confuse older FTP clients.
  73.  
    #async_abor_enable=YES
  74.  
    #
  75.  
    # By default the server will pretend to allow ASCII mode but in fact ignore
  76.  
    # the request. Turn on the below options to have the server actually do ASCII
  77.  
    # mangling on files when in ASCII mode.
  78.  
    # Beware that on some FTP servers, ASCII support allows a denial of service
  79.  
    # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
  80.  
    # predicted this attack and has always been safe, reporting the size of the
  81.  
    # raw file.
  82.  
    # ASCII mangling is a horrible feature of the protocol.
  83.  
    ascii_upload_enable=YES
  84.  
    ascii_download_enable=YES
  85.  
     
  86.  
    #
  87.  
    # You may fully customise the login banner string:
  88.  
    ftpd_banner=Welcome to lightnear FTP service.
  89.  
    #
  90.  
    # You may specify a file of disallowed anonymous e-mail addresses. Apparently
  91.  
    # useful for combatting certain DoS attacks.
  92.  
    #deny_email_enable=YES
  93.  
    # (default follows)
  94.  
    #banned_email_file=/etc/vsftpd/banned_emails
  95.  
    #
  96.  
    # You may specify an explicit list of local users to chroot() to their home
  97.  
    # directory. If chroot_local_user is YES, then this list becomes a list of
  98.  
    # users to NOT chroot().
  99.  
    chroot_local_user=YES
  100.  
    #chroot_list_enable=YES
  101.  
    # (default follows)
  102.  
    #chroot_list_file=/etc/vsftpd/chroot_list
  103.  
    #
  104.  
    # You may activate the "-R" option to the builtin ls. This is disabled by
  105.  
    # default to avoid remote users being able to cause excessive I/O on large
  106.  
    # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
  107.  
    # the presence of the "-R" option, so there is a strong case for enabling it.
  108.  
    ls_recurse_enable=YES
  109.  
    #
  110.  
    # When "listen" directive is enabled, vsftpd runs in standalone mode and
  111.  
    # listens on IPv4 sockets. This directive cannot be used in conjunction
  112.  
    # with the listen_ipv6 directive.
  113.  
    listen=YES
  114.  
    #
  115.  
    # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
  116.  
    # sockets, you must run two copies of vsftpd with two configuration files.
  117.  
    # Make sure, that one of the listen options is commented !!
  118.  
    #listen_ipv6=YES
  119.  
     
  120.  
    pam_service_name=vsftpd
  121.  
    userlist_enable=YES
  122.  
    userlist_deny=NO
  123.  
    local_root=/var/public_root
  124.  
    tcp_wrappers=YES
  125.  
    use_localtime=YES

 

 

三、增加FTP账号

 

  1.  
    [[email protected] ~]# useradd ftpuser -s /sbin/nologin
  2.  
    [[email protected] ~]# passwd ftpuser

ftpuser为账户名,passwd的作用为重设ftpuser的密码。

 

四、编辑user_list文件,允许cent用户访问

# vi /etc/vsftpd/user_list
  1.  
    # vsftpd userlist
  2.  
    # If userlist_deny=NO, only allow users in this file
  3.  
    # If userlist_deny=YES (default), never allow users in this file, and
  4.  
    # do not even prompt for a password.
  5.  
    # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
  6.  
    # for users that are denied.
  7.  
    root
  8.  
    bin
  9.  
    daemon
  10.  
    adm
  11.  
    lp
  12.  
    sync
  13.  
    shutdown
  14.  
    halt
  15.  
    mail
  16.  
    news
  17.  
    uucp
  18.  
    operator
  19.  
    games
  20.  
    nobody
  21.  
    ftpuser


五、建立我们的根目录,并设置访问权限

 

 

  1.  
    # mkdir /var/public_root
  2.  
    # chown -R cent /var/public_root
  3.  
    # chmod -R 755 /var/public_root


六、开启vsftpd服务

 

 

  1.  
    # service vsftpd start
  2.  
    Starting vsftpd for vsftpd: [ OK ]


七、开启21端口

 

 

#vi /etc/sysconfig/iptables 

在上面有行22 -j ACCEPT ,在下面照打一遍,但是把22改成21。改完之后,重启iptables。

 

 

#service iptables restart 

 

八、修改selinux

 

 

#getsebool -a | grep ftp 

执行上面命令,可以看到

 

 

  1.  
    ....
  2.  
    allow_ftpd_full_access off
  3.  
    ....
  4.  
    ....
  5.  
    ftp_home_dir off

将这两个权限都打开

 

  1.  
    #setsebool -P allow_ftpd_full_access 1
  2.  
    #setsebool -P ftp_home_dir 1

重启下vsftpd

 

 

#service vsftpd restart 

 

设置成默认开启。

# chkconfig vsftpd on

以上是关于centos6.8下配置vsftp的主要内容,如果未能解决你的问题,请参考以下文章

CentOS6.8下实现配置配额

centos6.8下redis的安装和配置

CentOS6.8下Nagios-4.2.0安装和配置

CentOS6.8 下MySQL5.6.29主从复制架构配置

Linux安装配置vsftp搭建FTP的详细配置

CentOS6.8下安装redis并配置开机自启动