如何在 CentOS 7.2 上安装带有 TLS 的 ProFTPD
本教程适用于这些操作系统版本
- CentOS 7.2
- CentOS 7
在此页
- 1 条初步说明
- 2 安装和配置 ProFTPD
- 2.1 安装:
- 2.2 创建 ProFTPD 用户
本教程描述了 ProFTPD 在 CentOS 7.2 服务器上的安装和配置。 ProFTPD 是用于 Unix 和 Linux 操作系统的 FTP 守护程序,并在 GNU 公共许可证 (GPL) 下分发。
1 初步说明
本教程基于 CentOS 服务器,因此在继续本教程之前,您应该设置基本的 CentOS 7.2 服务器安装。系统应该有一个静态 IP 地址。我在本教程中使用 192.168.1.100 作为我的 IP 地址,使用 server1.example.com 作为主机名。
2 安装配置ProFTPD
2.1 安装:
我们需要 EPEL 存储库中的软件,按如下方式启用它:
yum -y install epel-release
然后导入 EPEL GPG 密钥:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
并更新包:
yum -y update
我们将按如下方式安装 ProFTPD 和 OpenSSL:
yum install -y proftpd openssl proftpd-utils
我们需要启动该服务并使其在开机时自动启动。
systemctl start proftpd.service
systemctl enable proftpd.service如果您安装了 firewalld,则使用 firewall-cmd 配置防火墙以打开 FTP 端口:
firewall-cmd --add-service=ftp --permanent
firewall-cmd --reload我们可以检查 ProFTPD 版本如下:
proftpd -v
2.2 创建 ProFTPD 用户
我将为 ProFTPD 创建一个组 ftpgroup 和一个用户 tom。我会将 /ftpshare 设置为用户 tom 的主目录。
groupadd ftpgroup
接下来我将在 ftpgroup 中添加用户 srijan:
useradd -G ftpgroup tom -s /sbin/nologin -d /ftpshare
passwd tom[ ~]#
设置 ftpshare 目录的权限:
chmod -R 1750 /ftpshare/
现在我们已准备好进行 ProFTPD 连接。但是连接还没有加密,我们将在下一章解决这个问题。
3 在 ProFTPD 中启用 TLS
为了在 ProFTPD 中启用 TLS,打开 /etc/proftpd/proftpd.conf。编辑文件前,最好先备份原文件,再用nano编辑文件。
cp -pf /etc/proftpd.conf /etc/proftpd.conf.bak
nano /etc/proftpd.conf添加和修改以红色显示的行。
[...]
DefaultRoot ~ !adm PassivePorts 6000 6100
[...]
#<IfDefine TLS> TLSEngine on TLSRequired on TLSRSACertificateFile /etc/pki/tls/certs/proftpd.pem TLSRSACertificateKeyFile /etc/pki/tls/certs/proftpd.pem TLSCipherSuite ALL:!ADH:!DES TLSOptions NoCertRequest TLSVerifyClient off TLSRenegotiate ctrl 3600 data 512000 required off timeout 300 TLSLog /var/log/proftpd/tls.log # <IfModule mod_tls_shmcache.c> # TLSSessionCache shm:/file=/var/run/proftpd/sesscache # </IfModule> #</IfDefine>
[...]我添加了 6000 和 6100 端口以允许 ftp 的被动模式,类似地我将通过 CentOS firewalld 服务允许被动模式,如下所示:
firewall-cmd --add-port=6000-6100/tcp --permanent
firewall-cmd --reload我们可以检查端口状态如下:
firewall-cmd --list-ports
[ ~]#
此外,我们需要告诉 SELINUX 允许读/写文件。
setsebool -P allow_ftpd_full_access=1
为了使用 TLS,我们必须创建一个 SSL 证书。我将在/etc/pki/tls/certs 中创建它,我们可以生成 SSL 证书,如下所示:
openssl req -x509 -nodes -newkey rsa:1024 -keyout /etc/pki/tls/certs/proftpd.pem -out /etc/pki/tls/certs/proftpd.pem
根据您的选择将上述值用红色表示,我刚刚给出了一个例子。
现在出于安全目的,我将使证书仅可读,如下所示:
chmod 0440 /etc/pki/tls/certs/proftpd.pem
最后重启ProFTPD服务如下:
systemctl restart proftpd.service
详情如下:
Host=192.168.1.100
Protocol=FTP
User=tom
Port=可以留空,如果你没有自定义它的端口不是 21
Password=ftppassword(刚刚在上面创建)4 ProFTPD 中的匿名 ftp 访问
我们可以在 ProFTPD 中创建一个匿名 ftp 帐户,只需在 ProFTPD 配置文件中添加以下行:
nano /etc/proftpd.conf
并在文件末尾添加这些行。
[...]
###Anonymous share##### <Anonymous ~ftp> User ftp Group ftp UserAlias anonymous ftp DirFakeUser on ftp DirFakeGroup on ftp MaxClients 10 <Directory *> <Limit WRITE> DenyAll </Limit> </Directory> </Anonymous>现在我们需要重新启动 FTP 服务:
systemctl restart proftpd.service
现在通过 Filezilla 连接到 anon 帐户,如下所示:
按连接。
我们已使用匿名用户成功连接到服务器。
恭喜!现在我们已经在 CentOS 7.2 中成功配置了 ProFTPD 服务器环境:)
5个链接
- CentOS : http://www.centos.org/
- ProFTPD : http://www.proftpd.org/