在 Ubuntu 上搭建 FTPServer(FTP 服务器) 常见有两种方式:
下面先以 vsftpd 为例,这是最推荐、最常见的做法。
sudo apt update
sudo apt install vsftpd -y
安装完成后:
systemctl status vsftpd
应看到 active (running)。
编辑配置文件:
sudo nano /etc/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
allow_writeable_chroot=YES
pasv_min_port=30000
pasv_max_port=31000
保存后退出。
如果你不想用系统现有用户:
sudo useradd -m ftpuser
sudo passwd ftpuser
测试目录权限:
sudo chown ftpuser:ftpuser /home/ftpuser
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw allow 30000:31000/tcp
sudo ufw reload
sudo systemctl restart vsftpd
ftp localhost
ftp your_server_ip
或使用 FileZilla:
如果你说的 FTPServer = FTPS(加密),继续下面步骤。
sudo openssl req -x509 -nodes -days 365 \
-newkey rsa:2048 \
-keyout /etc/ssl/private/vsftpd.key \
-out /etc/ssl/certs/vsftpd.crt
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/certs/vsftpd.crt
rsa_private_key_file=/etc/ssl/private/vsftpd.key
sudo systemctl restart vsftpd
✅ 客户端(如 FileZilla)选择 FTP over TLS 即可。
/etc/shells 中缺少用户 shellecho /bin/bash | sudo tee -a /etc/shells
sudo chown -R ftpuser:ftpuser /home/ftpuser
| 项目 | vsftpd | ProFTPD |
|---|---|---|
| 性能 | 高 | 中 |
| 配置 | 简单 | 灵活 |
| 虚拟用户 | 弱 | 强 |
| FTPS | ✅ | ✅ |
如果你告诉我:
我可以给你一份 完全定制化的配置方案。