阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

[翻译]CentOS 7.0 上安装ProFTPD

141次阅读
没有评论

共计 4921 个字符,预计需要花费 13 分钟才能阅读完成。

本文讲述了在 CentOS 7.0 下安装和配置 ProFTPD 方法。ProFTPD 是一个针对 Unix 或者类 Unix 系统的 FTP 守护进程。ProFTPD 是在 GUN 通用公共许可协议(基本确立了 ProFTPD 作为自由软件的身份)下开发,发布的,这意味着只需要在 ProFTPD 包中包含完整的源代码或者在网站上发布预编译的二进制文件,就可以以任何方式出售,授权。任何人在任何时间点都可以修改该软件,只要修改后的软件也遵守 GNU PublicLicense 即可。

1 准备工作

本教程是基于 CentOS 7.0 的,在继续本教程之前,你应该先安装 CentOS 7.0。系统应该有一个静态 IP 地址。在本教程中使用 192.168.0.100 作为静态 IP 地址,用 server1.example.com 作为主机名。

2 安装 ProFTPD

2.1 安装配置:

使用如下命令安装有效的 EPEL(Extra Packages for Enterprise Linux EPEL, 企业版 Linux 附加软件包):

rpm -ivh http://dl.Fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm

我们首先使用如下命令安装 ProFTPD 和 OpenSSL:

yum install -y proftpd openssl proftpd-utils

使用如下命令开启 ProFTPD 服务:

systemctl start proftpd.service

systemctl enable proftpd.service

在 CentOS 7.0 中我们需要使用如下命令为 ftp 服务额外配置一下防火墙(Firewall-cmd):

firewall-cmd –add-service=ftp –permanent

firewall-cmd –reload

我们可以使用如下命令查看 ProFTPD 的安装版本:

proftpd -v

[root@server1 ~]# proftpd -v

ProFTPD Version 1.3.5

[root@server1 ~]#

2.2 创建 ProFTPD 用户

我会为 ProFTPD 创建一个组:ftpgroup 并且创建一个用户:srijan。我将用户 srijan 的主目录设置为 /ftpshare:

groupadd ftpgroup

接下来我将用户 srijan 添加到 ftpgroup 中:

useradd  -G ftpgroup srijan -s /sbin/nologin -d /ftpshare

passwd srijan

[root@server1 ~]# passwd srijan

Changing password for user srijan.

New password: <–ftppassword

Retype new password: <–ftppassword

passwd: all authentication tokens updated successfully.

[root@server1 ~]#

接下来,我们需要防止该目录被删除或者重命名,从而保护所有用户的数据,所以我们使用如下命令来改变该目录的访问权限:

chmod -R 1777 /ftpshare/

现在我们已经为连接 ProFTPD 做好了准备

现在我们可以使用用户名 srijan 和密码登录 ftp://192.168.0.100 了。

[翻译]CentOS 7.0 上安装 ProFTPD

[翻译]CentOS 7.0 上安装 ProFTPD

3 使 ProFTPD 中的 TLS(安全传输层协议:Transport Layer Security)有效

为了使 ProFTPD 中的 TLS 有效,我们需要使用如下命令打开 /etc/proftpd/proftpd.conf 并更改该文件,在编辑该文件之前最好备份原始文件:

cp /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>
[…]

我为 ftp 的被动模式添加了 6000 和 6100 两个端口号,类似的我会使用如下命令允许被动模式通过 CentOS 的防火墙服务:

firewall-cmd –add-port=6000-6100/tcp –permanent
firewall-cmd –reload

我们可以使用如下命令查看端口状态:

firewall-cmd –list-ports
[root@server1 ~]# firewall-cmd –list-ports
6000-6100/tcp
[root@server1 ~]#

另外我们需要通知 SELINUX(Security-Enhanced Linux) 允许对这些文件进行读写操作。

setsebool -P allow_ftpd_full_access=1

为了使用 TLS,我们必须创建一个 SSL 证书。我们可以使用如下命令在 /etc/pki/tls/certs 中创建它:

openssl req -x509 -nodes -newkey rsa:1024 -keyout /etc/pki/tls/certs/proftpd.pem -out /etc/pki/tls/certs/proftpd.pem 

[root@server1 certs]# openssl req -x509 -nodes -newkey rsa:1024 -keyout /etc/pki/tls/certs/proftpd.pem -out /etc/pki/tls/certs/proftpd.pem
Generating a 1024 bit RSA private key
……………………………..++++++
………++++++
writing new private key to ‘/etc/pki/tls/certs/proftpd.pem’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [XX]:<–DE
State or Province Name (full name) []:<–Hamburg
Locality Name (eg, city) [Default City]:<–Luneberg
Organization Name (eg, company) [Default Company Ltd]:<–ISPConfig
Organizational Unit Name (eg, section) []:<–Development
Common Name (eg, your name or your server’s hostname) []:<–server1.example.com
Email Address []:<–info@example.com
[root@server1 certs]#

上面红色字段标记的值由你给出,我只是给了一个例子而已。

为了安全起见我会用如下命令将该证书的访问权限修改为只读模式:

chmod  0440 /etc/pki/tls/certs/proftpd.pem

最后重启 ProFTPD 服务:

systemctl restart proftpd.service

我们可以通过 Filezilla 连接到 ProFTPD 服务器了,在连接服务器之前你必须在客户端中安装了 Filezilla。打开 Filezilla 并且做如下设置:

[翻译]CentOS 7.0 上安装 ProFTPD

详细信息:

Host = 192.168.0.100
Protocol = FTP
User = srijan
Port = 只要你没有自定义草果 21 个端口,这块可以使空白的
Password = ftppassword (之前设置的密码)

注意: 以上步骤中我们对连接进行了加密,所以我们将显式的使用 TLS 加密的 FTP。如果你没有配置 TLS,那么可以简单地使用 FTP 了。

[翻译]CentOS 7.0 上安装 ProFTPD

如上图所示,要求信任证书,点击 OK。

[翻译]CentOS 7.0 上安装 ProFTPD

它将通过 TLS 连接到 FTP 的共享目录。

4 在 ProFTPD 中通过匿名访问 ftp

我们只需要在 ProFTPD 配置文件中添加一些条目,就可以创建一个匿名的 ftp 帐号。

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>

添加完后我们需要重启服务:

systemctl restart proftpd.service

如下图所示通过 Filezilla 连接服务器:

[翻译]CentOS 7.0 上安装 ProFTPD

注意:以上步骤中我们对连接进行了加密,所以我们将显式的使用 TLS 加密的 FTP。如果你没有配置 TLS,那么可以简单地使用 FTP 了

点击 Connect:

[翻译]CentOS 7.0 上安装 ProFTPD

如上图所示,要求信任证书,点击 OK。

[翻译]CentOS 7.0 上安装 ProFTPD

至此,我们已经成功使用匿名账户连接到服务器了。

恭喜!我们已经成功在 CentOS 中配置 ProFTPD 服务器环境了:)

5 链接

CentOS : http://www.centos.org/

ProFTPD : http://www.proftpd.org/

Linux 下 ProFTPD 安装与配置 http://www.linuxidc.com/Linux/2013-06/86534.htm

Ubuntu 12.04 下 ProFTPD FTP 服务器配置 http://www.linuxidc.com/Linux/2013-03/81302.htm

Ubuntu 安装搭建 ProFTPD 服务器 http://www.linuxidc.com/Linux/2012-12/77113.htm

Linux VPS vsftp/ProFTPD FTP 时间差八小时的解决方法 http://www.linuxidc.com/Linux/2011-06/36780.htm

英文原文:How to install ProFTPD on CentOS 7.0

译者:ximsfei

本文由 Linux 公社翻译组 原创翻译  Linux 公社推出

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-12/110046.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计4921字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中