linux下vsftp的ls命令无法查看目录,无法上传下载文件的问题解决

本文详细介绍了在Linux环境下使用vsftp搭建FTP服务器时遇到的无法通过FTP命令查看目录及进行文件上传下载的问题,并提供了通过调整setsebool配置和重启服务来解决该问题的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在LINUX下vsftp建立一个FTP服务器,但通过ftp的命令控制台使用FTP时,ls无法查看目录, 当然更无法上传下载文件了!


出错如下 :


ftp> ls

227 Entering Passive Mode (192,168,2,222,110,161)
150 Here comes the directory listing.

226 Directory send OK.


ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
226 Directory send OK.


查看ftp的命令

ftp> help
Commands may be abbreviated.  Commands are:

!                       cr                     mdir               proxy              send
$                      delete             mget             sendport        site
account          debug             mkdir            put                 size
append          dir                    mls                pwd              status
ascii               disconnect      mode            quit               struct
bell                 form                modtime         quote           system
binary            get                   mput              recv               sunique
bye                glob                 newer           reget              tenex
case             hash               nmap             rstatus          trace
ccc                 help               nlist                rhelp              type
cd                  idle                 ntrans            rename          user
cdup              image           open              reset              umask
chmod           lcd                 passive         restart            verbose
clear              ls                   private            rmdir             ?
close            macdef          prompt           runique
cprotect        mdelete         protect          safe


通过 passive 开启和关闭 PASV模式, 再ls 也是同样的问题, 最后在网上找到了解决办法,最重要的是man ftpd_selinux,解决这个问题只要:
1. setsebool -P ftpd_disable_trans 1
2. service vsftpd restart 


当然了,解决这个问题的办法还有一个, 就是禁用selinux

如何禁用呢?

vi /etc/sysconfig/selinux
SELINUX=enforcing --> SELINUX=disabled

但是这个修改需要重新启动计算机,reboot 一下。


下面是其他常见的setsebool 命令

BOOLEANS
       SELinux  policy is based on least privilege required and may also be customizable by setting
       a boolean with setsebool.

       Allow ftp servers to read and write files with the public_content_rw_t file type.

       setsebool -P allow_ftpd_anon_write on

       Allow ftp servers to read or write files in the user home directories.

       setsebool -P ftp_home_dir on

       Allow ftp servers to read or write all files on the system.

       setsebool -P allow_ftpd_full_access on

       Allow ftp servers to use cifs for public file transfer services.

       setsebool -P allow_ftpd_use_cifs on

       Allow ftp servers to use nfs for public file transfer services.

       setsebool -P allow_ftpd_use_nfs on

       system-config-selinux is a GUI tool available to customize SELinux policy settings.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

langeldep

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值