centos7下安装配置FTP服务器

vsftpd(Very Secure FTP Daemon)是unix/linux下安全快速的FTP服务器。本文主要记录如何在centos7下安装配置基本的ftp服务。

安装vsftpd


在终端中使用root用户运行下列命令安装vsftpd包

yum install vsftpd ftp -y

 vsftpd配置文件说明


使用root用户编辑vsftpd配置文件/etc/vsftpd/vsftpd.conf

保持良好习惯,在编辑前我们需要备份下该文件。

cp /etc/vsftpd/vsftpd.conf /etc/vsftpd.conf.bak

 然后我们开始编辑vsftpd.conf

vi /etc/vsftpd/vsfptd.conf

 找文件中的下列几行

 [...]
## Disable anonymous login ##
## 禁用匿名登录## anonymous_enable=NO ## 启用ASCII模式数据传输 ## ascii_upload_enable=YES ascii_download_enable=YES # 是否允许执行任何可以修改文件系统的命令,默认是NO
# 这里我们设置为启用(YES) write_enable=YES ## Add at the end of this file ## use_localtime=YES ##从2.3.5之后,vsftpd增强了安全检查,如果用户被限定在了其主目录下,则该用户的主目录不能再具有写权限了!如果检查发现还有写权限,就会报该错误。  500 OOPS: vsftpd: refusing to run with writable root inside chroot() Login failed.  421 Service not available, remote server has closed connection  要修复这个错误,可以用命令chmod a-w /home/user去除用户主目录的写权限,注意把目录替换成你自己的。或者你可以在vsftpd的配置文件中增加下面这一项:allow_writeable_chroot=YES ## allow_writeable_chroot=YES
##设置PAM认证服务的配置文件名称,该文件存放在/etc/pam.d/ pam_service_name=vsftpd ## 此项配置/etc/vsftpd.user_list中指定的用户也不能访问服务器,若添加userlist_deny=No,则仅仅/etc/vsftpd.user_list文件中的用户可以访问,其他用户都不可以访问服务器。如过userlist_enable=NO,userlist_deny=YES,则指定使文件/etc/vsftpd.user_list中指定的用户不可以访问服务器,其他本地用户可以访问服务器。 userlist_enable=YES ##在VSFTPD中使用TCP_Wrappers远程访问控制机制 ## tcp_wrappers=YES

启动vsftpd服务并设置开机启动


systemctl enable vsftpd
systemctl start vsftpd

防火墙设置


允许ftp服务及21端口通过防火墙

firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --permanent --add-service=ftp

重启防火墙

firewall-cmd --reload
原文地址:https://www.cnblogs.com/deargrape/p/6704478.html