CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CentOS 7.2 安装和配置 FTP 服务器大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

1. 安装vsftpd 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 #安装vsftpd yum install -y vsftpd #设置开机启动 system

1. 安装vsftpd

 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
#安装vsftpd yum install -y vsftpd #设置开机启动 systemctl enable vsftpd.@R_450_9260@ce # 重启 @R_450_9260@ce vsftpd restart # 查看vsftpd服务的状态 systemctl status vsftpd.@R_450_9260@ce

2. 配置vsftpd.conf

  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    #备份配置文件 cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak #执行以下命令 sed -i "s/anonymous_enable=YES/anonymous_enable=NO/g" '/etc/vsftpd/vsftpd.conf' sed -i "s/#anon_upload_enable=YES/anon_upload_enable=NO/g" '/etc/vsftpd/vsftpd.conf' sed -i "s/#anon_mkdir_write_enable=YES/anon_mkdir_write_enable=YES/g" '/etc/vsftpd/vsftpd.conf' sed -i "s/#chown_uploads=YES/chown_uploads=NO/g" '/etc/vsftpd/vsftpd.conf' sed -i "s/#async_abor_enable=YES/async_abor_enable=YES/g" '/etc/vsftpd/vsftpd.conf' sed -i "s/#ascii_upload_enable=YES/ascii_upload_enable=YES/g" '/etc/vsftpd/vsftpd.conf' sed -i "s/#ascii_download_enable=YES/ascii_download_enable=YES/g" '/etc/vsftpd/vsftpd.conf' sed -i "s/#ftpd_bAnner=Welcome to blah FTP @R_450_9260@ce./ftpd_bAnner=Welcome to FTP @R_450_9260@ce./g" '/etc/vsftpd/vsftpd.conf' #添加下列内容到vsftpd.conf末尾 use_localtime=YES listen_port=21 chroot_local_user=YES idle_session_timeout=300 guest_enable=YES guest_username=vsftpd user_config_dir=/etc/vsftpd/vconf data_connection_timeout=1 virtual_use_local_privs=YES pasv_min_port=10060 pasv_max_port=10090 accept_timeout=5 connect_timeout=1

    3. 建立用户文件

    @H_77_262@
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    #第一行用户名,第二行密码,不能使用root为用户名 vi /etc/vsftpd/virtusers chris 123456 chang 123456

    @L_502_2@4. 生成用户数据文件

      
      
  • 1
  • 2
  • 3
  • 4
  • 5
    • 1
    • 2
    • 3
    • 4
    • 5
    db_load -T -t hash -f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db #设定PAM验证文件,并指定对虚拟用户数据库文件进行读取 chmod 600 /etc/vsftpd/virtusers.db

    5. @L_944_21@/etc/pam.d/vsftpd文件

      
      
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    # @L_944_21@前先备份 cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak # 将auth及account的所有配置行均注释掉 vi /etc/pam.d/vsftpd auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers # 如果系统为32位,上面改为lib

    6. 新建系统用户vsftpd,用户目录为/home/vsftpd

      
      
  • 1
  • 2
  • 3
    • 1
    • 2
    • 3
    #用户登录终端设为/bin/false(即:使之不能登录系统) useradd vsftpd -d /home/vsftpd -s /bin/false chown -R vsftpd:vsftpd /home/vsftpd

    7.建立虚拟用户个人配置文件

      
      
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • @H_170_36@mkdir /etc/vsftpd/vconf cd /etc/vsftpd/vconf #这里建立两个虚拟用户配合文件 touch chris chang #建立用户根目录 mkdir -p /home/vsftpd/chris/ #编辑chris用户配置文件内容如下,其他用户类似 vi chris local_root=/home/vsftpd/chris/ write_enable=YES anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES

    8. 防火墙设置

      
      
  • 1
  • 2
  • 3
  • 4
    • 1
    • 2
    • 3
    • 4
    vi /etc/sysconfig/iptables #编辑iptables文件添加如下内容,开启21端口 -A INPUT -@H_292_387@m state --state NEW -@H_292_387@m tcp -p tcp --dport 21 -j ACCEPT

    9. 重启vsftpd服务器

      
      
  • 1
    • 1
    @R_450_9260@ce vsftpd restart

    10. 使用CuteFtp/FlashFTP等软件连接测试

    大佬总结

    以上是大佬教程为你收集整理的CentOS 7.2 安装和配置 FTP 服务器全部内容,希望文章能够帮你解决CentOS 7.2 安装和配置 FTP 服务器所遇到的程序开发问题。

    如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

    本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
    如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。