文件共享 ftp服务器
ftp服务构建 File Transfer Protocol Server
默认使用端口20、21、其中端口20(数据端口)用于传输数据(主动模式) ,端口21(控制端口)用于客户端发出相关的FTP指令。
ftp协议有2种工作模式:
主动模式:ftp服务器主动向客户端发送连接请求
被动模式:ftp 的默认工作模式,ftp服务器等待客户端发送连接请求
linux系统使用的ftp服务器软件为vsftp (very secure ftp daemon)
具有高安全性、传输速度快、以及支持虚拟用户验证等特点
配置文件 /etc/vsftpd/vsftpd.conf
安装vsftpd
# yum -y install vsftpd
防火墙默认不开放ftp传输协议使用的端口,设置添加ftp服务,永久生效
[root@Linux ~]# systemctl start firewalld [root@Linux ~]# firewall-cmd --permanent --add-service=ftp success [root@Linux ~]# firewall-cmd --reload success
关闭SELinux
在/etc/selinux/config文件中,将第7行的SELINUX=enforcing 修改为
SELINUX=disabled,通过这种方式修改后需要重新启动才能生效。
[root@Linux ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
临时关闭SELinux
# setenforce 0
启动vsftpd服务,并设置开机启动
# systemctl start vsftpd # systemctl enable vsftpd
查看vsftpd状态
# systemctl status vsftpd
测试:复制一个hosts文件到 /var/ftp/目录下
[root@Linux ~]# cp -rf /etc/hosts /var/ftp/ [root@Linux ~]# ls /var/ftp/ hosts pub
打开浏览器输入:ftp://47.93.209.191/ 即可查看并下载ftp服务器上的hosts文件
vsftpd服务默认开启匿名模式,在该模式下任何人都无需提供密码,可以直接登录到ftp服务器
注意:匿名并非无任何记录,例如上次以ftp身份进行访问
[root@Linux ~]# grep ftp /etc/passwd ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin