在深入研究在CentOS上安装FTP之前,我们需要了解一下它的使用和安全性. FTP 是一种非常高效且精心优化的协议,用于在计算机系统之间传输文件. FTP已经使用和改进了几十年了.为了通过延迟或速度有效地在网络上传输文件,FTP是一个很好的选择.比SAMBA或SMB更多.
但是,FTP确实存在一些安全问题.实际上,一些严重的安全问题. FTP使用非常弱的纯文本身份验证方法.出于这个原因,经过身份验证的会话应该依赖于sFTP或FTPS,其中TLS用于登录和转移会话的端到端加密.
通过上述警告,简单的旧FTP仍然在今天的商业环境中使用.主要用途是匿名FTP文件存储库.在这种情况下,无需进行身份验证即可下载或上载文件.匿名FTP使用的一些例子是 :
大型软件公司仍然使用匿名ftp存储库,允许Internet用户下载共享软件和补丁.
允许互联网用户上传和下载公共文档.
部分应用程序将通过FTP自动将加密的,存档的日志或配置文件发送到存储库.
因此,作为CentOS管理员,能够安装和配置FTP仍然是一项设计技能.
我们将使用名为 vsFTP 的FTP守护程序或非常安全的FTP守护程序. vsFTP已经在开发中使用了一段时间.它以安全,易于安装和配置而着称,并且可靠.
第1步 : 使用YUM软件包管理器安装vsFTPd.
[root @ centos] #yum -y install vsftpd.x86_64
第2步 : 配置vsFTP以使用systemctl启动时启动.
[root @ centos] #systemctl start vsftpd [root @ centos] #systemctl enable vsftpd 从/etc/systemd/system/multi- user.target.wants/vsftpd.service创建符号链接到/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 /ftpSet 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
启用匿名上传
CHOWN上传的文件归系统所有 ftp 用户
chown_uploads = YES
chown_username = ftp
将vsftp使用的系统用户更改为ftp用户:nopriv_user = ftp
设置自定义横幅用户在登录前阅读.
ftpd_banner =欢迎使用我们的匿名FTP回购.所有连接都受到监控和记录.
我们只设置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>