安裝 vsftpd
yum install -y vsftpd
編輯 ftp 配置文件
vi /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
#anonymous_enable=YES
chroot_local_user=YES
#去掉前面的註釋
#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd/chroot_list
#不受限制的用戶列表,用不用都OK
allow_writeable_chroot=YES
#加上這行解決了無法登陸的問題
啓動/重新啓動 ftp
service vsftpd start
service vsftpd restart
設置開機啓動ftp
chkconfig vsftpd on
防火牆配置 (iptables)
#安裝iptables防火牆
yum install iptables-services #安裝
vi /etc/sysconfig/iptables
在 iptables 中開發 21 端口,CentOS7 中默認開啓的是 firewall 防火牆,可以參考 http://help.aliyun.com/knowledge_detail/6700252.html?spm=5176.7618386.5.3.AeHhDY 設置 iptables 防火牆
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
防火牆重新啓動
#service iptables restart
systemctl restart iptables.service #最後重啓防火牆使配置生效
systemctl enable iptables.service #設置防火牆開機啓動
建立ftp賬戶
#爲 /path/you/want 目錄創建 ftpUserName 用戶
useradd -d /path/you/want -s /sbin/nologin ftpUserName
修改密碼
passwd ftpUserName
設置賬戶權限
chown -R ftpUserName.ftpUserName /path/you/set
原文:http://www.centoscn.com/image-text/install/2015/0227/4748.html
備註:如果客戶端 ftp 連接不成功,可以參考 http://blog.csdn.net/u011310774/article/details/49658867