如何配置 PureFTPd 和 FileZilla 以在 CentOS 7.2 上使用 TLS 会话

1 初步说明

您应该在 CentOS 7.2 服务器上设置工做的 PureFTPd 设置,例如本教程所示:在 CentOS 7.2 上具备 PureFTPd、MariaDB 和虚拟用户的 FTP 服务器(包括配额和带宽管理)node

2 安装OpenSSL

TLS 须要开放 SSL;要安装 OpenSSL,咱们只需运行:centos

yum -y install openssl

3 配置PureFTPd

打开/etc/pure-ftpd/pure-ftpd.conf...服务器

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

若是要容许 FTPTLS 会话,请将TLS设置为1session

[...]
# 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设置为2ui

[...]
# 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设置为0this

[...]
# 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 行前面的 #:spa

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

并保存更改的配置文件。插件

4 为 TLS 建立 SSL 证书

为了使用 TLS,咱们必须建立 SSL 证书。我在/etc/ssl/私有/中建立它,所以我首先建立该目录:rest

mkdir -p /etc/ssl/private/

以后,咱们能够按照以下方式生成 SSL 证书:code

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

为了将 FTP 与 TLS 一块儿使用,您须要一个支持 TLS 的 FTP 客户端,例如FileZilla或 Firefox FireFTP 插件。

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

1.png

选择使用纯FTPd与 TLS 的服务器;在"服务器类型"下拉菜单中,选择"经过 TLS 要求显式 FTP",而不是普通FTP

2.png

如今,您能够链接到服务器。若是首次执行此操做,则必须接受服务器的新 SSL 证书,由于咱们在此处使用自签名 SSL 证书:

3.png

若是一切顺利,您如今应该登陆到服务器上:

4.png

6 连接

相关文章
相关标签/搜索