一、安装ftp服务
[root@localhost ~]# yum install -y vsftpd
二、关闭防火墙 [centos7为例]
- 查看防火墙状态,running 代表正在运行
[root@localhost ~]# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-08-26 00:43:26 CST; 1h 12min ago
Docs: man:firewalld(1)
Main PID: 604 (firewalld)
CGroup: /system.slice/firewalld.service
└─604 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopi
- 关闭防火墙
[root@localhost ~]# systemctl stop firewalld
- 永久关闭防火墙
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
三、修改selinux配置,关闭selinux
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
四、配置vsftpd
- 查看配置vsftpd文件
[root@localhost ~]# cd /etc/vsftpd/
[root@localhost vsftpd]# ll
total 20
-rw-------. 1 root root 125 Apr 1 12:55 ftpusers
-rw-------. 1 root root 361 Apr 1 12:55 user_list
-rw-------. 1 root root 5116 Apr 1 12:55 vsftpd.conf
-rwxr--r--. 1 root root 338 Apr 1 12:55 vsftpd_conf_migrate.sh
- 配置ftpusers,将root注释
[root@localhost vsftpd]# vim ftpusers
# Users that are not allowed to login via ftp
# root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
~
- 配置user_list,将root注释
[root@localhost vsftpd]# vim user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
# root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
- 配置vsftpd.conf
anonymous_enable=NO //禁止匿名登陆
chown_uploads=YES //允许上传文件
anon_upload_enable=YES //selinux未关闭时允许上传文件
anon_mkdir_write_enable=YES //允许创建可写的目录
五、重启服务并加入开机自启动即可
[root@localhost ~]# sysytemctl restart vsftpd
[root@localhost ~]# sysytemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.