如何配置 PureFTPd 以在 CentOS 7 上使用 TLS 会话如何配置 PureFTPd 以在 CentOS 7 上使用 TLS 会话如何配置 PureFTPd 以在 CentOS 7 上使用 TLS 会话如何配置 PureFTPd 以在 CentOS 7 上使用 TLS 会话
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何配置 PureFTPd 以在 CentOS 7 上使用 TLS 会话

本教程适用于这些操作系统版本

  • 中央操作系统 5.5

在此页

  1. 1 条初步说明
  2. 2 安装 OpenSSL
  3. 3 配置 PureFTPd
  4. 4 为 TLS 创建 SSL 证书
  5. 5 为 TLS 配置 FileZilla
  6. 6 个链接

本文介绍如何配置 PureFTPd 以在 CentOS 7 服务器上接受 TLS 会话。普通 FTP 是一种不安全的协议,因为所有密码和所有数据都以明文形式传输。通过使用 TLS,可以对整个通信进行加密,从而使 FTP 更加安全。

1 初步说明

你应该在你的 CentOS 7 服务器上有一个工作的 PureFTPd 设置,例如如本教程所示:在 CentOS 7 上使用 PureFTPd 和 MySQL 进行虚拟主机(包括配额和带宽管理)。

2 安装OpenSSL

TLS 需要 OpenSSL;要安装 OpenSSL,我们只需运行:

yum install openssl

3 配置 PureFTPd

打开 /etc/pure-ftpd/pure-ftpd.conf...

nano /etc/pure-ftpd/pure-ftpd.conf

如果要允许 FTP 和 TLS 会话,请将 TLS 设置为 1:

[...]
# This option can accept three values :
# 0 : disable SSL/TLS encryption layer (default).
# 1 : accept both traditional and encrypted sessions.
# 2 : refuse connections that don't use SSL/TLS security mechanisms,
#     including anonymous sessions.
# Do _not_ uncomment this blindly. Be sure that :
# 1) Your server has been compiled with SSL/TLS support (--with-tls),
# 2) A valid certificate is in place,
# 3) Only compatible clients will log in.

TLS                      1
[...]

如果您只想接受 TLS 会话(不接受 FTP),请将 TLS 设置为 2:

[...]
# This option can accept three values :
# 0 : disable SSL/TLS encryption layer (default).
# 1 : accept both traditional and encrypted sessions.
# 2 : refuse connections that don't use SSL/TLS security mechanisms,
#     including anonymous sessions.
# Do _not_ uncomment this blindly. Be sure that :
# 1) Your server has been compiled with SSL/TLS support (--with-tls),
# 2) A valid certificate is in place,
# 3) Only compatible clients will log in.

TLS                      2
[...]

要根本不允许 TLS(仅 FTP),请将 TLS 设置为 0:

[...]
# This option can accept three values :
# 0 : disable SSL/TLS encryption layer (default).
# 1 : accept both traditional and encrypted sessions.
# 2 : refuse connections that don't use SSL/TLS security mechanisms,
#     including anonymous sessions.
# Do _not_ uncomment this blindly. Be sure that :
# 1) Your server has been compiled with SSL/TLS support (--with-tls),
# 2) A valid certificate is in place,
# 3) Only compatible clients will log in.

TLS                      0
[...]

然后去掉下面2行前面的#:

TLSCipherSuite           HIGH
CertFile                 /etc/ssl/private/pure-ftpd.pem

并保存修改后的配置文件。

4 为 TLS 创建 SSL 证书

为了使用 TLS,我们必须创建一个 SSL 证书。我在 /etc/ssl/private/ 中创建它,因此我首先创建该目录:

mkdir -p /etc/ssl/private/

之后,我们可以生成 SSL 证书,如下所示:

openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem

国家名称(2 个字母代码)[XX]:<-- 输入您的国家名称(例如,\DE\)。
州或省名称(全名)[]:<-- 输入您的州或省名称。
地点名称(例如,城市)[默认城市]:<-- 输入您的城市。
组织名称(例如,公司)[默认有限公司]:<-- 输入您的组织名称(例如,您公司的名称)。
组织单位名称(例如,部门)[]:<-- 输入您的组织单位名称(例如 \IT 部门\)。
通用名称(例如,您的姓名或您的服务器主机名)[]:<-- 输入系统的完全限定域名(例如 \server1.example.com\)。
电子邮件地址 []:<-- 输入您的电子邮件地址。

更改 SSL 证书的权限:

chmod 600 /etc/ssl/private/pure-ftpd.pem

最后,重启 PureFTPd:

systemctl restart pure-ftpd.service

就是这样。您现在可以尝试使用您的 FTP 客户端进行连接;但是,您应该将 FTP 客户端配置为使用 TLS - 请参阅下一章如何使用 FileZilla 执行此操作。

5 为 TLS 配置 FileZilla

为了使用带有 TLS 的 FTP,您需要一个支持 TLS 的 FTP 客户端,例如 FileZilla 或 Firefox 中的 FireFTP 插件。

在 FileZilla 中,打开站点管理器:

选择使用带 TLS 的 PureFTPd 的服务器;在服务器类型下拉菜单中,选择需要通过 TLS 的显式 FTP 而不是普通的 FTP:

现在您可以连接到服务器了。如果您是第一次这样做,您必须接受服务器的新 SSL 证书:

如果一切顺利,您现在应该已登录到服务器:

6个链接

  • PureFTPd:http://www.pureftpd.org/
  • FileZilla:http://filezilla-project.org/
  • CentOS:http://www.centos.org/

©2015-2025 艾丽卡 support@alaica.com