本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
安装vsftpd
yum -y install vsftpd
修改如下内容:
vi /etc/vsftpd/vsftpd.conf
anonymous_enable=NO #是否允许匿名,默认no
write_enable=YES #具有写权限
local_umask=022 #本地用户创建文件或目录的掩码
connect_from_port_20=YES #开启20端口
listen_port=XXX #ftp的端口号
local_root=/home/wwwroot/sanxi.info/usr/plugins/ #修改为自己想要的指定目录
创建用户,指定用户为系统用户并指定家目录路径
useradd -d /home/wwwroot/sanxi.info/usr/plugins/ -s /sbin/nologin sanxi
passwd sanxi #此处为上述命令所创建之用户
Changing password for user sanxi.
New password:
passwd: all authentication tokens updated successfully.
启动并设置vsftpd开机启动
systemctl start vsftpd.service
systemctl enable vsftpd.service
报错:
状态: 正在连接 103.72.144.219:21...
状态: 连接建立,等待欢迎消息...
状态: 不安全的服务器,不支持 FTP over TLS。
命令: USER sanxi
响应: 331 Please specify the password.
命令: PASS ********
响应: 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
错误: 严重错误: 无法连接到服务器
状态: 已从服务器断开
解决:
vim /etc/vsftpd.conf add the following
allow_writeable_chroot=YES #
local_root=/home/wwwroot/sanxi.info/usr/plugins/ #修改默认用户家目录为此目录
chroot_local_user=YES #正常密码登录
注释掉listen_ipv6=YES或者改为NO
systemctl restart vsftpd.service
报错:无权限
命令: PASV
响应: 227 Entering Passive Mode (103,72,144,219,163,209).
命令: STOR /Akina/images/smilies/alu/zhoumei.png
响应: 553 Could not create file.
错误: 严重文件传输错误
解决:
chmod -R 777 /home/wwwroot/sanxi.info/usr/plugins/
systemctl restart vsftpd.service