CentOS7.2 (安装镜像CentOS-7-x86_64-DVD-1611)服务器
本文默认使用root用户操做tcp
实现CentOS7.2上安装vsftpd,使用新建立的ftpuser用户即可在局域网其余服务器上上传或下载文件,防火墙有效测试
//安装vsftpd #yum install -y vsftpd
//检查服务是否enable #systemctl list-unit-files | grep enabled
//若是没有enabled,就像下面这样启动 #systemctl enable vsftpd //设置开机启动 #systemctl enable vsftpd.service //重启 #service vsftpd restart //查看vsftpd服务的状态 #systemctl status vsftpd.service
#mkdir /home/ftp //建立ftpuser用户,root组,目录/home/ftp #useradd -g root -M -d /home/ftp -s /sbin/nologin ftpuser //设置ftpuser密码 #passwd ftpuser #输入密码 //把/home/ftp的全部权给ftpuser.root #chown -R ftpuser.root /home/ftp
//备份配置文件 #cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak //配置vsftpd,禁止匿名用户登录 #vi /etc/vsftpd/vsftpd.conf //更改禁止匿名访问 (INSERT)anonymous_enable=YES 改成 anonymous_enable=NO (ESC):wq
//配置防火墙,开通21端口。(注意,Centos7.2 使用firewalld代替了原来的iptables) #firewall-cmd --zone=public --add-port=21/tcp --permanent //让防火墙设置生效 #firewall-cmd --reload
//查找ftp相关SELinux状态 #getsebool -a | grep ftp //打开ftpd_full_access #setsebool -P ftpd_full_access on //-P写入磁盘,不会重启消失,但耗时较长,耐心等待
在局域网其余服务器上,使用ftp命令访问ftp服务器spa