龙空技术网

如何在centos7下搭建FTP服务?

JAVA小邓 171

前言:

如今朋友们对“centos68ftp客户端”可能比较关怀,大家都想要剖析一些“centos68ftp客户端”的相关资讯。那么小编也在网上网罗了一些对于“centos68ftp客户端””的相关知识,希望我们能喜欢,大家一起来了解一下吧!

1、检查是否已安装vsftp

# 未输出信息,表示未安装vsftprpm -qa |grep vsftpd

2、通过yum安装vsftp

yum install vsftpd -y

3、ftp启动、重启、停止、状态查询命令

service vsftpd start         #启动ftpservice vsftpd stop         #停止ftpservice vsftpd restart      #重启ftpservice vsftpd status       #查询ftp状态

4、设置为开机启动

chkconfig vsftpd on

5、设置配置文件

5.1、编辑文件

vi /etc/vsftpd/vsftpd.conf

5.2、找到并修改如下内容

# #设置不允许匿名账户登录anonymous_enable=NO

5.3、在文件末尾新增配置

# 防止用户有写入权限时报错allow_writeable_chroot=YES# 设置用户的根目录local_root=/home/www

5.4、重启ftp

service vsftpd restart

6、创建ftp用户

6.1、创建用户组

groupadd ftpgroups

6.2、创建用户

useradd -d /home/www -g ftpgroups ftptest# 命令解释# useradd								 添加用户命令# -d /home/www		指定用户根目录# -g ftpgroups				加入用户组# ftptest                  用户名

6.3、设置用户密码

passwd ftptest

6.4、设置不允许用于系统登录

usermod -s /sbin/nologin ftptest

7、设置文件权限

chmod 755 /home/www

8、设置目录拥有者

chown -R ftptest:root /home/www

9、设置防火墙

9.1、查看防火墙状态,如果未启动,直接跳过本步骤

systemctl status firewalld

9.2、开放20、21端口(阿里云服务器还需配置安全组开放防火墙)

firewall-cmd --permanent --zone=public --add-port=20/tcpfirewall-cmd --permanent --zone=public --add-port=20/udpfirewall-cmd --permanent --zone=public --add-port=21/tcpfirewall-cmd --permanent --zone=public --add-port=21/udpfirewall-cmd --reload #重新载入

至此ftp服务安装成功,如果出现不能访问或不能写入的情况,就还需要设置SELinux(关闭)

# 查看SELinux状态,如果SELinux status参数为enabled即为开启状态sestatus -v# 临时关闭(不用重启机器)setenforce 0

标签: #centos68ftp客户端