1.安裝vsftp
yum install -y vsftpd
2.設置開機啟動
systemctl enable vsftpd
3.啟動ftp服務
service vsftpd start
4.打開防火墻
firewall-cmd --zone=public --add-port=21/tcp --permanent
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --reload
5.添加用戶
/usr/sbin/adduser -d /usr/share/nginx/html/ftp -g ftp -s /sbin/nologin test
6.設置用戶密碼
passwd test
7.設置權限
chown -R ftpyonghu:root /home/data
setsebool -P ftpd_full_access on
8.修改vsftp配置文件,禁用匿名登錄,鎖定用戶目錄
vi /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
chroot_local_user=YES
allow_writeable_chroot=YES
輸入 :x 保存退出
關閉SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注釋掉
#SELINUXTYPE=targeted #注釋掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
500 OOPS: vsftpd: refusing to run with writable root inside chroot()
解決方法
allow_writeable_chroot=YES
>[info]備注: 如果使用阿里云,請在安全組中加入20/21 端口, IP 0.0.0.0/0
出錯:服務器發回了不可路由的地址。使用服務器地址代替
>[info]解決方法:更改Filezilla設置,編輯-設置-連接-FTP-被動模式,將“使用服務器的外部ip地址來代替”改為“回到主動模式”即可。
## centos7安裝配置vsftp
時間:2017-03-18 01:02來源:blog.csdn.net 作者:sfeng95的博客 舉報 點擊:1232次
其實搭建ftp服務器不難,但是網絡上的資料很多不全,對新手來說就是個天坑,我也曾跳過天坑,還浪費了很多生命值,所以我要寫這篇博客為民除坑!
FTP正常可用的話,如果要添加新用戶
/usr/sbin/adduser -d /usr/share/nginx/html/face/cronjob/ftp/3 -g ftp -s /sbin/nologin sun
passwd sun
Centos查看端口占用情況命令,比如查看80端口占用情況使用如下命令:
lsof -i tcp:80
列出所有端口
netstat -ntlp
使用被動模式
allow_writeable_chroot=YES
listen_port=21
pasv_enable=YES
pasv_min_port=10060
pasv_max_port=10090
#pasv_promiscuous=YES