vsftpd 安裝
yum 安裝 vsftpd
yum -y install vsftpd
檢查是否安裝
rpm -qa|grep vsftpd
建立 ftp 使用者的目錄
mkdir /ftphome
建立虛擬使用者可以使用 ftp 不能登陸系統
usadd ftpuser -d /ftpfile -s /sbin/nolog
passwd ftpuser
//輸入密碼
修改 ftphome 許可權並新增使用者配置檔案最後需要將配檔案引用到 ftp 配置中
chown -R ftpuser.ftpuser /ftphome
vim chroot_list :wq 儲存退出
修改 selinux
vim /etc/selinux/config 修改 SELINUX=disable
配置 vsftpd.conf
vim /etc/vsftpd/vsftpd.conf
local_root=/ftphome
#chroot_local_user=YES
anon_root=/ftphome
use_localtime=YES

#匿名
#anonymous_enable=YES
anonymous_enable=NO
local_enable=YES
# Uncomment this to enable any form of FTP write command.
write_enable=YES
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd’s)
local_umask=022
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
#chown_uploads=YES
#chown_username=whoever
xferlog_std_format=YES
#xferlog_file=/var/log/xferlog
xferlog_std_format=YES
#ascii_upload_enable=YES
#ascii_download_enable=YES
ftpd_banner=Welcome to FTP Server
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
#listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
#pasv_enable=YES
pasv_min_port=61001
pasv_max_port=62000
allow_writeable_chroot=YES
新增 ftp 開機自啟
systemctl enable vsftpd.service
安裝 ftp 客戶端檢驗
yum -y install ftp
配置 firewall 防火牆
firewall 常用命令
1 、重啟、關閉、開啟 firewalld.service 服務
service firewalld restart 重啟
service firewalld start 開啟
service firewalld stop 關閉
2 、檢視 firewall 服務狀態
systemctl status firewall
3 、檢視 firewall 的狀態
firewall-cmd –state
4 、檢視防火牆規則
firewall-cmd –list-all
配置防火牆規則(兩種方式)  令名方式
vim /etc/firewalld/zones/public.xml






圖形方式
yum -y install firewall-config
//安裝成功後使用下面的命令在彈出介面進行配置
firewall-config
熟悉 iptables 的可以按照下面的方式配置  由於 centos7 自帶的是 firewall 沒有 iptables 我們要禁用 firewall 安裝配置配置 iptables  禁用 firewall
systemctl stop firewalld.service #停止 firewall
systemctl disable firewalld.service #禁止 firewall 開機啟動
安裝 iptables
#先檢查是否安裝了 iptables
service iptables status
#安裝 iptables
yum install -y iptables
#升級 iptables
yum update iptables
#安裝 iptables-services
yum install iptables-services
配置 iptables
vim /etc/sysconfig/iptables
-A INPUT -p TCP –dport 61001:62000 -j ACCEPT
-A OUTPUT -p TCP –sport 61001:62000 -j ACCEPT
-A INPUT -p TCP –dport 20 -j ACCEPT
-A OUTPUT -p TCP –sport 20 -j ACCEPT
-A INPUT -p TCP –dport 21 -j ACCEPT
-A OUTPUT -p TCP –sport 21 -j ACCEPT
修改 iptable 開機啟動
systemctl enable iptables.service #iptables 開機啟動
重新啟動機器(修改了 selinux 重新啟動讓配置生效)
常用命令
systemctl stop firewalld.service #停止 firewall
systemctl disable firewalld.service #禁止 firewall 開機啟動
systemctl stop iptables.service #停止 iptables
systemctl disable iptables.service #禁止 iptables 開機啟動
systemctl restart vsftpd.service #重新啟動 ftp 服務