1、安装
yum install vsftpd -y
2、启动
service vsftpd start
3、检查端口
netstat -nltp | grep 21
4、编辑 /etc/vsftpd/vsftpd.conf,配置
# 禁用匿名用户 anonymous_enable=NO # 禁止切换根目录 chroot_local_user=YES
5、重启服务
service vsftpd restart
6、创建一个用户 ftpuser
useradd ftpuser
7、为用户
ftpuser
设置密码 echo "ggW9ogOE" | passwd ftpuser --stdin
8、限制该用户仅能通过 FTP 访问
限制用户
ftpuser
只能通过 FTP 访问服务器,而不能直接登录服务器:
usermod -s /sbin/nologin ftpuser
9、为用户
并约定:
ftpuser
创建主目录并约定:
/data/ftp
为主目录, 该目录不可上传文件/data/ftp/pub
文件只能上传到该目录下
mkdir -p /data/ftp/pub
10、创建登录欢迎文件
echo "Welcome to use FTP service." > /data/ftp/welcome.txt
11、设置访问权限:
chmod a-w /data/ftp && chmod 777 -R /data/ftp/pub
12、设置为用户的主目录:
usermod -d /data/ftp ftpuser