phpseclib rawlist返回false

问题描述

我最近使用AWS Transfer系列创建了一个SFTP站点。使用FileZilla,我可以连接到该站点,遍历目录,上传和下载文件而没有问题。但是,当我使用PHPseclib SFTP库时,我可以使用用户名/密码进行连接,但是rawlist()nlist()返回的是false。我仔细研究了PHPseclib代码,发现真正的错误消息是“访问被拒绝的US-ASCII” 。我试图进行更深入的研究,但是我对SFTP / SSH通信还不够熟悉,无法理解我在看什么。任何对此的信息将不胜感激。

这是SFTP日志的结果:

-> NET_SFTP_INIT (0.0001s)
00000000  00:00:00:03                                      ....

<- NET_SFTP_VERSION (1.8121s)
00000000  00:00:00:03                                      ....

-> NET_SFTP_REALPATH (0.0001s)
00000000  00:00:00:01:2e                                   .....

<- NET_SFTP_NAME (0.0518s)
00000000  00:00:00:01:00:00:00:11:2f:74:72:6b:2d:69:6e:73  ......../test-sf
00000010  69:67:68:74:2d:73:66:74:70:00:00:00:00:00:00:00  tp-bucket.......
00000020  00                                               .

-> NET_SFTP_OPENDIR (0.0001s)
00000000  00:00:00:10:2f:64:6f:63:75:6d:65:6e:74:73:2f:66  ..../documents/f
00000010  69:6c:65:73                                      iles

<- NET_SFTP_STATUS (0.2694s)
00000000  00:00:00:03:00:00:00:0d:41:63:63:65:73:73:20:64  ........Access d
00000010  65:6e:69:65:64:00:00:00:08:55:53:2d:41:53:43:49  enied....US-ASCI
00000020  49                                               I

FileZilla日志:

2020-11-12 09:56:37 5158 1 Trace: We claim version: SSH-2.0-FileZilla_3.51.0
2020-11-12 09:56:38 5158 1 Trace: Remote version: SSH-2.0-AWS_SFTP_1.0
2020-11-12 09:56:38 5158 1 Trace: Using SSH protocol version 2
2020-11-12 09:56:38 5158 1 Trace: Doing ECDH key exchange with curve nistp256 and hash SHA-256 (unaccelerated)
2020-11-12 09:56:38 5158 1 Trace: Host key fingerprint is:
2020-11-12 09:56:38 5158 1 Trace: ssh-rsa 2048 a9:8d:e5:96:58:90:37:4b:42:60:24:66:ee:dd:72:a0 XKJp5iGNAQkwdbld69XapgzgIiiAgzji1T66HhhdRWU=
2020-11-12 09:56:38 5158 1 Trace: Initialised AES-256 GCM outbound encryption
2020-11-12 09:56:38 5158 1 Trace: Initialised AES256 GCM outbound MAC algorithm (in ETM mode) (required by cipher)
2020-11-12 09:56:38 5158 1 Trace: Initialised AES-256 GCM inbound encryption
2020-11-12 09:56:38 5158 1 Trace: Initialised AES256 GCM inbound MAC algorithm (in ETM mode) (required by cipher)
2020-11-12 09:56:38 5158 1 Trace: Pageant is running. Requesting keys.
2020-11-12 09:56:38 5158 1 Trace: Failed to get reply from Pageant
2020-11-12 09:56:38 5158 1 Status: Using username "blahlblahblah". 
2020-11-12 09:56:38 5158 1 Command: Pass: ******************
2020-11-12 09:56:38 5158 1 Trace: Sent password
2020-11-12 09:56:39 5158 1 Trace: Access granted
2020-11-12 09:56:39 5158 1 Trace: opening main session channel
2020-11-12 09:56:39 5158 1 Trace: Opened main channel
2020-11-12 09:56:39 5158 1 Trace: Started a shell/command
2020-11-12 09:56:39 5158 1 Status: Connected to s-7d09f176684848268.server.transfer.us-east-2.amazonaws.com
2020-11-12 09:56:42 5158 1 Trace: Remote working directory is /test-sftp-bucket
2020-11-12 09:56:42 5158 1 Trace: CSftpConnectOpData::ParseResponse() in state 3
2020-11-12 09:56:42 5158 1 Trace: CControlSocket::Resetoperation(0)
2020-11-12 09:56:42 5158 1 Trace: CSftpConnectOpData::Reset(0) in state 3
2020-11-12 09:56:42 5158 1 Trace: CControlSocket::SendNextCommand()
2020-11-12 09:56:42 5158 1 Trace: CSftpListOpData::Send() in state 0
2020-11-12 09:56:42 5158 1 Status: Retrieving directory listing...
2020-11-12 09:56:42 5158 1 Trace: CSftpChangeDirOpData::Send() in state 0
2020-11-12 09:56:42 5158 1 Trace: CSftpChangeDirOpData::Send() in state 1
2020-11-12 09:56:42 5158 1 Command: pwd
2020-11-12 09:56:42 5158 1 Response: Current directory is: "/test-sftp-bucket"
2020-11-12 09:56:42 5158 1 Trace: CSftpChangeDirOpData::ParseResponse() in state 1
2020-11-12 09:56:42 5158 1 Trace: CControlSocket::Resetoperation(0)
2020-11-12 09:56:42 5158 1 Trace: CSftpChangeDirOpData::Reset(0) in state 1
2020-11-12 09:56:42 5158 1 Trace: CSftpListOpData::SubcommandResult(0) in state 1
2020-11-12 09:56:42 5158 1 Trace: CControlSocket::SendNextCommand()
2020-11-12 09:56:42 5158 1 Trace: CSftpListOpData::Send() in state 2
2020-11-12 09:56:42 5158 1 Trace: CSftpListOpData::Send() in state 3
2020-11-12 09:56:42 5158 1 Command: ls
2020-11-12 09:56:42 5158 1 Status: Listing directory /test-sftp-bucket
2020-11-12 09:56:42 5158 1 Trace: CSftpListOpData::ParseResponse() in state 3
2020-11-12 09:56:42 5158 1 Trace: CControlSocket::Resetoperation(0)
2020-11-12 09:56:42 5158 1 Trace: CSftpListOpData::Reset(0) in state 3
2020-11-12 09:56:42 5158 1 Status: Directory listing of "/test-sftp-bucket" successful
2020-11-12 09:56:51 5158 1 Trace: CControlSocket::SendNextCommand()
2020-11-12 09:56:51 5158 1 Trace: CSftpListOpData::Send() in state 0
2020-11-12 09:56:51 5158 1 Status: Retrieving directory listing of "/test-sftp-bucket/documents"...
2020-11-12 09:56:51 5158 1 Trace: CSftpChangeDirOpData::Send() in state 0
2020-11-12 09:56:51 5158 1 Trace: CSftpChangeDirOpData::Send() in state 2
2020-11-12 09:56:51 5158 1 Command: cd "/test-sftp-bucket/documents"
2020-11-12 09:56:51 5158 1 Response: New directory is: "/test-sftp-bucket/documents"
2020-11-12 09:56:51 5158 1 Trace: CSftpChangeDirOpData::ParseResponse() in state 2
2020-11-12 09:56:51 5158 1 Trace: CControlSocket::Resetoperation(0)
2020-11-12 09:56:51 5158 1 Trace: CSftpChangeDirOpData::Reset(0) in state 2
2020-11-12 09:56:51 5158 1 Trace: CSftpListOpData::SubcommandResult(0) in state 1
2020-11-12 09:56:51 5158 1 Trace: CControlSocket::SendNextCommand()
2020-11-12 09:56:51 5158 1 Trace: CSftpListOpData::Send() in state 2
2020-11-12 09:56:51 5158 1 Trace: CSftpListOpData::Send() in state 3
2020-11-12 09:56:51 5158 1 Command: ls
2020-11-12 09:56:51 5158 1 Status: Listing directory /test-sftp-bucket/documents
2020-11-12 09:56:52 5158 1 Trace: CSftpListOpData::ParseResponse() in state 3
2020-11-12 09:56:52 5158 1 Trace: CControlSocket::Resetoperation(0)
2020-11-12 09:56:52 5158 1 Trace: CSftpListOpData::Reset(0) in state 3
2020-11-12 09:56:52 5158 1 Status: Directory listing of "/test-sftp-bucket/documents" successful
2020-11-12 09:56:53 5158 1 Trace: CControlSocket::SendNextCommand()
2020-11-12 09:56:53 5158 1 Trace: CSftpListOpData::Send() in state 0
2020-11-12 09:56:53 5158 1 Status: Retrieving directory listing of "/test-sftp-bucket/documents/files"...
2020-11-12 09:56:53 5158 1 Trace: CSftpChangeDirOpData::Send() in state 0
2020-11-12 09:56:53 5158 1 Trace: CSftpChangeDirOpData::Send() in state 2
2020-11-12 09:56:53 5158 1 Command: cd "/test-sftp-bucket/documents/files"
2020-11-12 09:56:53 5158 1 Response: New directory is: "/test-sftp-bucket/documents/files"
2020-11-12 09:56:53 5158 1 Trace: CSftpChangeDirOpData::ParseResponse() in state 2
2020-11-12 09:56:53 5158 1 Trace: CControlSocket::Resetoperation(0)
2020-11-12 09:56:53 5158 1 Trace: CSftpChangeDirOpData::Reset(0) in state 2
2020-11-12 09:56:53 5158 1 Trace: CSftpListOpData::SubcommandResult(0) in state 1
2020-11-12 09:56:53 5158 1 Trace: CControlSocket::SendNextCommand()
2020-11-12 09:56:53 5158 1 Trace: CSftpListOpData::Send() in state 2
2020-11-12 09:56:53 5158 1 Trace: CSftpListOpData::Send() in state 3
2020-11-12 09:56:53 5158 1 Command: ls
2020-11-12 09:56:53 5158 1 Status: Listing directory /test-sftp-bucket/documents/files
2020-11-12 09:56:53 5158 1 Trace: CSftpListOpData::ParseResponse() in state 3
2020-11-12 09:56:53 5158 1 Trace: CControlSocket::Resetoperation(0)
2020-11-12 09:56:53 5158 1 Trace: CSftpListOpData::Reset(0) in state 3
2020-11-12 09:56:53 5158 1 Status: Directory listing of "/test-sftp-bucket/documents/files" successful

解决方法

您使用了错误的路径。

使用GUI SFTP客户端登录并检查那里的路径。然后在您的PHP代码中使用相同的完整路径。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...