在Ubuntu上为FTPServer(FTP over SSL/TLS)设置SSL加密,可以按照以下步骤进行:
首先,确保你的系统是最新的,并安装vsftpd
和ssl-cert
包。
sudo apt update
sudo apt install vsftpd ssl-cert
编辑vsftpd
的配置文件/etc/vsftpd.conf
。
sudo nano /etc/vsftpd.conf
在文件中添加或修改以下配置项:
# 启用SSL/TLS
ssl_enable=YES
# 强制使用SSL/TLS
force_local_data_ssl=YES
force_local_logins_ssl=YES
# 使用SSL/TLS证书和密钥
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
# 允许匿名用户使用SSL/TLS
allow_anon_ssl=NO
# 允许本地用户使用SSL/TLS
local_enable=YES
# 允许写操作
write_enable=YES
# 其他安全设置
chroot_local_user=YES
allow_writeable_chroot=YES
保存并关闭配置文件后,重启vsftpd
服务以应用更改。
sudo systemctl restart vsftpd
你可以使用openssl
命令来验证SSL/TLS连接是否正常工作。
openssl s_client -connect your_server_ip:21 -starttls ftp
如果一切配置正确,你应该会看到SSL/TLS握手成功的消息。
确保你的防火墙允许FTP和SSL/TLS流量。
sudo ufw allow 21/tcp
sudo ufw allow 990/tcp # FTPS数据连接端口(可选)
sudo ufw reload
在你的FTP客户端中,确保使用FTPS协议,并指定端口21进行连接。如果需要,也可以指定数据连接的端口(通常是990)。
通过以上步骤,你应该能够在Ubuntu上成功为FTPServer设置SSL加密。