Linux 管理员 - 安装匿名 FTP

在深入研究如何在 CentOS 上安装 FTP 之前,我们需要了解一些有关其使用和安全性的知识。FTP 是一种非常高效且经过精心设计的协议,用于在计算机系统之间传输文件。FTP 已经使用和改进了几十年。对于在有延迟的网络上高效传输文件或追求速度,FTP 是一个不错的选择。比 SAMBA 或 SMB 都好。

但是,FTP 确实存在一些安全问题。实际上,存在一些严重的安全问题。FTP 使用一种非常薄弱的​​纯文本身份验证方法。因此,经过身份验证的会话应依赖于 sFTP 或 FTPS,其中 TLS 用于登录和传输会话的端到端加密。

尽管存在上述注意事项,普通的旧 FTP 在当今的商业环境中仍然有用。主要用途是匿名 FTP 文件存储库。在这种情况下,无需身份验证即可下载或上传文件。匿名 FTP 使用的一些示例是 −

  • 大型软件公司仍然使用匿名 FTP 存储库,允许互联网用户下载共享软件和补丁。

  • 允许互联网用户上传和下载公共文档。

  • 某些应用程序会自动通过 FTP 将加密的存档日志或配置文件发送到存储库。

因此,作为 CentOS 管理员,能够安装和配置 FTP 仍然是一项设计技能。

我们将使用一个名为 vsFTP 或 Very Secure FTP Daemon 的 FTP 守护程序。vsFTP 已在开发中使用了一段时间。它以安全、易于安装和配置和可靠而闻名。

步骤 1 −使用 YUM 包管理器安装 vsFTPd。

[root@centos]# yum -y install vsftpd.x86_64

步骤 2 − 使用 systemctl 将 vsFTP 配置为在启动时启动。

[root@centos]# systemctl start vsftpd 
[root@centos]# systemctl enable vsftpd 
Created symlink from /etc/systemd/system/multi-
user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

步骤 3 −配置 FirewallD 以允许 FTP 控制和传输会话。

[root@centos]#firewall-cmd --add-service=ftp --permanent
success
[root@centos]#

确保我们的 FTP 守护进程正在运行。

[root@centos]# netstat -antup | grep vsftp 
tcp6       0       0 :::21       :::*       LISTEN       13906/vsftpd         
[root@centos]#

步骤 4 − 配置 vsFTPD 以进行匿名访问。

创建根 FTP 目录

[root@centos]# mkdir /ftp

将 FTP 根目录的所有者和组更改为 ftp

[root@centos]# chown ftp:ftp /ftp
Set minimal permissions for FTP root:

[root@centos]# chmod -R 666 /ftp/

[root@centos]# ls -ld /ftp/
drw-rw-rw-. 2 ftp ftp 6 Feb 27 02:01 /ftp/

[root@centos]#

在本例中,我们授予用户对整个根 FTP 树的读/写访问权限。

配置 /etc/vsftpd/vsftpd.conf"

[root@centos]# vim /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.

我们将要更改 vsftp.conf 文件中的以下指令。

  • 通过取消注释 anon_mkdir_write_enable=YES

  • 启用匿名上传
  • 将上传的文件更改为系统 ftp 用户所拥有的文件

    chown_uploads = YES

    chown_username = ftp

  • 将 vsftp 使用的系统用户更改为 ftp 用户:nopriv_user = ftp

  • 设置用户登录前要阅读的自定义横幅。

    ftpd_banner = 欢迎来到我们的匿名 FTP Repo。所有连接均受到监控和记录。

  • 让我们仅设置 IPv4 连接 −

    listen = YES

    listen_ipv6 = NO

现在,我们需要重新启动或 HUP vsftp 服务以应用我们的更改。

[root@centos]# systemctl restart vsftpd

让我们连接到我们的 FTP 主机并确保我们的 FTP 守护进程正在响应。

[root@centos rdc]# ftp 10.0.4.34 
Connected to localhost (10.0.4.34). 
220 Welcome to our Anonymous FTP Repo. All connections are monitored and logged. 
Name (localhost:root): anonymous 
331 Please specify the password. 
Password: 
'230 Login successful. 
Remote system type is UNIX. 
Using binary mode to transfer files. 
ftp>