本文将详细介绍当用户能够成功登录到FTP服务器但遇到无法进行文件下载或上传的问题时,应采取的有效排查与解决步骤。
构建了一个FTP服务器,并通过命令行登录成功,但在尝试执行下载、上传或列出文件操作(如使用`ls`)时遇到问题。无论是在主动模式还是被动模式下开启PASV功能后再次尝试这些操作都遇到了同样的问题。
在主动模式下的情况如下:
```shell
# 主动模式
$ pftp -v -A -d 211.159.185.xxx
Connected to 211.159.185.198 (211.159.185.xxx).
220 (vsFTPd 3.0.2)
Name (211.159.185.xxx:liangzh): lebaFtpUser
USER lebaFtpUser
331 Please specify the password.
Password:
PASS XXXX
230 Login successful.
SYST
215 UNIX Type: L8
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
ftp: setsockopt (ignored): Permission denied
PORT 192,168,10,144,210,113
200 PORT command successful. Consider using PASV.
LIST
425 Failed to establish connection.
```
在被动模式下的情况如下:
```shell
# 被动模式
$ ftp -v -p -d 211.159.185.198
Connected to 211.159.185.198 (211.159.185.198).
220 (vsFTPd 3.0.2)
Name (211.159.185.198:liangzh): lebaFtpUser
USER lebaFtpUser
331 Please specify the password.
Password:
PASS XXXX
230 Login successful.
SYST
215 UNIX Type: L8
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
ftp: setsockopt (ignored): Permission denied
PASV
227 Entering Passive Mode (211,159,185,198,134,173).
ftp: connect: Connection timed out
```
为了解决上述问题,可以按照以下步骤操作:
- 使用`setsebool -P ftpd_disable_trans 1`命令。
- 执行`service vsftpd restart`重启vsFTPd服务。