温馨提示×

Debian FTP Server如何安装与配置

小樊
42
2025-02-23 10:01:42
栏目: 智能运维
亿速云云数据库,读写分离,安全稳定,弹性扩容,低至0.3元/天!! 点击查看>>

在Debian系统上安装和配置FTP服务器,通常使用vsftpd(Very Secure FTP Daemon)是一个不错的选择。以下是详细的步骤:

1. 安装vsftpd

首先,更新你的包列表并安装vsftpd

sudo apt update
sudo apt install vsftpd

2. 配置vsftpd

安装完成后,你需要编辑vsftpd的配置文件。默认情况下,配置文件位于/etc/vsftpd.conf

sudo nano /etc/vsftpd.conf

在配置文件中,你可以根据需要进行以下修改:

  • 允许本地用户登录

    local_enable=YES
    
  • 允许写操作

    write_enable=YES
    
  • 允许匿名用户登录(如果你需要):

    anonymous_enable=YES
    
  • 设置匿名用户的根目录

    anon_root=/var/ftp
    
  • 限制匿名用户的上传和下载速度

    anon_max_rate=50KB/s
    
  • 启用被动模式(如果你的客户端在防火墙后面):

    pasv_enable=YES
    pasv_min_port=1024
    pasv_max_port=1048
    
  • 使用本地用户认证

    local_enable=YES
    chroot_local_user=YES
    allow_writeable_chroot=YES
    
  • 禁用FTP命令列表

    list_enable=NO
    
  • 启用SSL/TLS加密(推荐):

    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/ssl/private/vsftpd.pem
    rsa_private_key_file=/etc/ssl/private/vsftpd.pem
    

    你需要生成SSL证书和密钥文件:

    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
    

3. 重启vsftpd服务

保存并关闭配置文件后,重启vsftpd服务以应用更改:

sudo systemctl restart vsftpd

4. 配置防火墙

如果你使用的是ufw防火墙,确保允许FTP流量:

sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw allow 1024:1048/tcp
sudo ufw enable

5. 测试FTP连接

你可以使用FTP客户端(如FileZilla)连接到你的服务器,测试FTP连接是否正常。

  • 主机:你的服务器IP地址
  • 用户名:本地用户名
  • 密码:用户密码

如果你启用了SSL/TLS,确保在客户端选择使用SSL/TLS连接。

通过以上步骤,你应该能够在Debian系统上成功安装和配置一个FTP服务器。

亿速云「云数据库 MySQL」免部署即开即用,比自行安装部署数据库高出1倍以上的性能,双节点冗余防止单节点故障,数据自动定期备份随时恢复。点击查看>>

推荐阅读:Debian上FileZilla如何与其他软件协同工作

0