简体   繁体   English

Underfined offset: -1 ErrorException 在尝试连接到远程服务器时从 phpseclib 抛出的含义是什么?

[英]What is the meaning of Underfined offset: -1 ErrorException thrown from phpseclib when trying to connect to remote server?

I am trying to login to a remote server using phpseclib Net_SSH2->login() function.我正在尝试使用 phpseclib Net_SSH2->login() 函数登录到远程服务器。 I am getting a connection timeout error, therefore I added $ssh->getLastError() to get a more clear error message but all I get is我收到连接超时错误,因此我添加了 $ssh->getLastError() 以获得更清晰的错误消息,但我得到的只是

exception 'ErrorException' with message 'Undefined offset: -1'带有消息“未定义偏移:-1”的异常“ErrorException”

along with the stack trace.连同堆栈跟踪。 I am wondering what does Undefined offset mean here and most importantly what does the number -1 refer to?我想知道这里未定义的偏移量是什么意思,最重要的是数字 -1 指的是什么? Thanks!!谢谢!!

Here's my code:这是我的代码:

$ssh = new \Net_SSH2('host.address');
$key = new \Crypt_RSA();
$key->setPassword('');
$key->loadKey(file_get_contents('keyfile.ppk'));
try
{
    if ($login = $ssh->login('username', $key))
    {
        \Log::error('Success');
        \Log::info($login);
        \Log::error('-----------------------');

    } else {
        \Log::error('Failed');
        \Log::error($ssh->getErrors());
        \Log::error($ssh->getLastError());
        \Log::error('-----------------------');
     }

 } catch(\Exception $e) {
     \Log::error('Exception');
     \Log::error($ssh->getErrors());
     \Log::error($ssh->getLastError());
     \Log::error('-----------------------');
 }

I figured that the exception is being thrown from inside the login function of php seclib.我认为异常是从 php seclib 的登录函数内部抛出的。 The reason was that I had to white-list my IP address on the target server, so it was the attempt to connect to the target server that was failing due to a timeout.原因是我必须在目标服务器上将我的 IP 地址列入白名单,因此尝试连接到目标服务器由于超时而失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM