https://blog.csdn.net/weixin_42193489/article/details/94181973?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control
sed -i 's/^anonymous_enable=.*/anonymous_enable=NO/g' /etc/vsftpd/vsftpd.conf
echo "userlist_deny=NO" >> /etc/vsftpd/vsftpd.conf
useradd -d /home/ftpuser -s /sbin/nologin ftpuser
echo "123456" |passwd --stdin ftpuser
echo "ftpuser" >> /etc/vsftpd/user_list
sed -i 's/^#chroot_local_user=YES/chroot_local_user=YES/g' /etc/vsftpd/vsftpd.conf
echo "allow_writeable_chroot=YES" >> /etc/vsftpd/vsftpd.conf
echo "pasv_min_port=10000" >> /etc/vsftpd/vsftpd.conf
echo "pasv_max_port=10010" >> /etc/vsftpd/vsftpd.conf
systemctl restart vsftpd
firewall-cmd --add-port=10000-10010/tcp add-port=21/tcp --permanent
systemctl restart firewalld
[root@localhost vsftpd]# ftp -n
ftp> open 192.168.1.41 21
Connected to 192.168.1.41 (192.168.1.41).
220 (vsFTPd 3.0.2)
ftp> user ftpuser 123456
331 Please specify the password.
230 Login successful.
ftp> ls
227 Entering Passive Mode (192,168,1,41,138,128).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 0 Jan 01 08:25 a.txt
226 Directory send OK.
ftp> bye
221 Goodbye.
[root@localhost vsftpd]#
usermod -s /sbin/nologin ftpuser (限制用户ftpuser只可以ftp)
usermod -s /sbin/bash ftpuser (如果需要,解除限制)
usermod -d /home/www/ ftpuser (更改用户ftpuser的主目录为www) chown ftpuser:ftpuser /home/www