CentOS7 架设 FTP 服务
大概操作流程
之前已经安装了 vsftpd 服务,并修改了配置
目前的状况是浏览器端可以登录,但无法显示文件列表
- 开机并启动 vsfptd
# 启动服务 service vsftpd start # 停止服务 service vsftpd stop # 重启服务 service vsftpd restart # 查看状态 service vsftpd status
- Docker 中安装了 ftp 命令行工具,登录时提示错误
vsftpd: refusing to run with writable root inside chroot()
- 更改挂载目录的拥有者,仍然提示错误
- 挂载硬盘出错
mount /dev/sdb is write-protected mounting read-only
mount: unknown filesystem type '(null)'
- 硬盘格式为 ntfs,格式化为linux支持的格式可以解决该问题,但硬盘中有数据,放弃了该方法
- 安装
ntfs-3g
,使用该工具挂载硬盘 - 命令行登录ftp,提示错误
500 Illegal PORT command
- 将 vsftpd 设置为被动模式,增加 vsftpd 配置项
# 开启被动模式 pasv_enable=YES # 被动模式最低端口 pasv_min_port=30000 # 被动模式最高端口 pasv_max_port=31000
- 仍然看不到文件列表
- 下载 ftp 客户端,使用 filezilla 登录 ftp
- 发现将 ntfs 挂载之后目录权限均为 root,使用 chown 更改所属用户没有效果,后来通过 ntfs-3g 挂载时设置用户和用户组为 vsftpd 用户
- SELinux 在访问 ftp 时收到警告
- 设置 SELinux 对 ftp 的控制,允许访问目录
# 查看 SELinux 中 ftp 权限 getsebool -a | grep ftp # 允许 ftp 访问目录 setsebool -P tftp_home_dir 1 setsebool -P allow_ftpd_full_access 1
- 解决错误
vsftpd: refusing to run with writable root inside chroot()
,在 vsftpd 配置文件中添加allow_writeable_chroot=YES
- ftp 仍然无法显示挂载硬盘的目录列表,原因是设置 ftp 为被动模式,防火墙阻止了之前设置的用于传输数据的被动模式端口 30000-31000
- 批量开放防火墙端口
firewall-cmd --permanent --zone=public --add-port=30000-31000/tcp firewall-cmd --reload
- 设置开机启动 vsftpd 服务
chkconfig vsftpd on
- 设置开机自动挂载 NTFS 硬盘
# 编辑 /etc/fstab 文件 UUID=831df52d-baad-4902-bcce-6128cec95411 /home/vsftpd/ftp ntfs-3g defaults 0 0
参考
- vsftpd:500 OOPS: vsftpd: refusing to run with
- 如何更改linux文件的拥有者及用户组(chown和chgrp)
- vsftpd 服务器报错:500 OOPS: vsftpd: refusing to run with writable root inside chroot()
- vsftpd配置文件详解
- Centos/Linux 挂载移动ntfs硬盘
- Centos 7 挂载 NTFS 分区
- 500 Illegal PORT command的问题(FTP主被动模式)
- CentOS下vsftp设置、匿名用户&本地用户设置、PORT、PASV模式设置
- CentOS 6和CentOS 7防火墙的关闭
- linux中ftp查看不到文件列表的问题
- 如何更改linux文件的拥有者及用户组(chown和chgrp)
- Linux查看用户所属的组
- Linux 系统的 NTFS-3G 权限
- 查看 SELinux状态及关闭SELinux
- CentOS7 搭建vsftpd详细教程
- vsftpd设置后无法登陆,解决OOPS: vsftpd: refusing to run with writable root inside chroot()
- vsftpd不能显示文件目录的解决方法
- Centos防火墙设置与端口开放的方法
- CentOS 7 开放防火墙端口命令
- CentOS7下firewall批量开放端口
- CentOs 设置开机启动vsftpd服务
- CentOS设置设备开机自动挂载
- centos7.2挂载NTFS格式移动硬盘
- 通过UUID挂载磁盘