温馨提示×

CentOS FTP Server SSL/TLS加密设置

小樊
67
2025-04-26 21:39:05
栏目: 云计算

在CentOS上设置FTP服务器以使用SSL/TLS加密,通常涉及以下几个步骤:

  1. 安装FTP服务器软件

    • 你可以选择vsftpd、ProFTPD或Pure-FTPd等FTP服务器软件。这里以vsftpd为例。
  2. 安装vsftpd

    sudo yum install vsftpd
    
  3. 配置vsftpd

    • 编辑vsftpd配置文件 /etc/vsftpd/vsftpd.conf
      sudo vi /etc/vsftpd/vsftpd.conf
      
    • 确保以下配置项存在并正确设置:
      listen=YES
      listen_ipv6=NO
      anonymous_enable=NO
      local_enable=YES
      write_enable=YES
      local_umask=022
      dirmessage_enable=YES
      use_localtime=YES
      xferlog_enable=YES
      connect_from_port_20=YES
      chroot_local_user=YES
      secure_chroot_dir=/var/run/vsftpd/empty
      pam_service_name=vsftpd
      userlist_enable=YES
      tcp_wrappers=YES
      
  4. 启用SSL/TLS

    • 安装Certbot以获取SSL证书(如果你还没有的话):
      sudo yum install certbot
      sudo certbot certonly --standalone -d yourdomain.com
      
    • 编辑vsftpd配置文件 /etc/vsftpd/vsftpd.conf,添加或修改以下配置项:
      ssl_enable=YES
      allow_anon_ssl=NO
      force_local_data_ssl=YES
      force_local_logins_ssl=YES
      ssl_tlsv1=YES
      ssl_sslv2=NO
      ssl_sslv3=NO
      rsa_cert_file=/etc/letsencrypt/live/yourdomain.com/fullchain.pem
      rsa_private_key_file=/etc/letsencrypt/live/yourdomain.com/privkey.pem
      ssl_ciphers=HIGH
      
  5. 重启vsftpd服务

    sudo systemctl restart vsftpd
    
  6. 配置防火墙

    • 确保防火墙允许FTP和SSL/TLS流量:
      sudo firewall-cmd --permanent --add-service=ftp
      sudo firewall-cmd --permanent --add-service=https
      sudo firewall-cmd --reload
      
  7. 测试FTP连接

    • 使用FTP客户端连接到你的服务器,并确保使用SSL/TLS加密(通常会显示为FTPS或FTPES)。

通过以上步骤,你应该能够在CentOS上成功设置一个使用SSL/TLS加密的FTP服务器。

0