Linux 搭建FTP服务

ftp 服务安装

1 安装
yum -y install vsftpd
2 添加用户,密码

useradd -s /sbin/nologin -d /home/ftp_test ftp_test
passwd ftp_test


3禁止匿名访问
vi /etc/vsftpd/vsftpd.conf

anonymous_enable=NO

4 启动

systemctl start vsftpd.service

5 filezilla 客户端验证

6 限制只能访问用户自己的目录,对其他目录不可见

chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list

创建文件 touch /etc/vsftpd/chroot_list

chroot_list 中的用户不受限制

7 遇到问题

问题1 没有chroot_list 文件
500 OOPS: could not read chroot() list file:/etc/vsftpd/chroot_list 解决 创建 chroot_list 文件

问题2
当我们限定了用户不能跳出其主目录之后,使用该用户登录FTP时往往会遇到这个错误:

500 OOPS: vsftpd: refusing to run with writable root inside chroot ()

这个问题发生在最新的这是由于下面的更新造成的:

- Add stronger checks for the configuration error of running with a writeable root directory inside a chroot(). This may bite people who carelessly turned on chroot_local_user but such is life.

从2.3.5之后,vsftpd增强了安全检查,如果用户被限定在了其主目录下,则该用户的主目录不能再具有写权限了!如果检查发现还有写权限,就会报该错误。
要修复这个错误,可以用命令chmod a-w /home/user去除用户主目录的写权限,注意把目录替换成你自己的。或者你可以在vsftpd的配置文件中增加下列两项中的一项:

allow_writeable_chroot=YES

问题3 

vsftp上传文件出现553 Could not create file

首先在ftp的目录中创建一个目录,然后设置权限为777
$ sudo mkdir /var/ftp/write
$sudo chmod -R 777 /var/ftp/write
然后修改vsftp的配置文件/etc/vsftpd.conf文件
在最后添加上
local_root=/var/ftp

问题4

客户端建立连接慢,尤其是离线状态

reverse_lookup_enable=NO

原文地址:https://www.cnblogs.com/zhangeamon/p/7929087.html