1

I am having problems with phpseclib Net SSH2 libraries, the connection to the server is impossible, I tried to find a solution but I can not find it.

Notice: Error reading from socket in C:\wamp64\www\v5\library\backend\global\class\lib\Net\SSH2.php on line 3494

Notice: Connection closed by server in C:\wamp64\www\v5\library\backend\global\class\lib\Net\SSH2.php on line 1497

include('lib/Net/SSH2.php');
define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
$ssh = new Net_SSH2('IP');
if (!$ssh->login('root', 'password')) {
     echo $ssh->isConnected() ? 'bad username or password' : 'unable to establish connection';
}

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
echo $ssh->getLog();

Here are the recovered error logs:

<-
00000000  53:53:48:2d:32:2e:30:2d:4f:70:65:6e:53:53:48:5f  SSH-2.0-OpenSSH_
00000010  36:2e:37:70:31:20:44:65:62:69:61:6e:2d:35:2b:64  6.7p1 Debian-5+d
00000020  65:62:38:75:38:0d:0a                             eb8u8..

->
00000000  53:53:48:2d:32:2e:30:2d:70:68:70:73:65:63:6c:69  SSH-2.0-phpsecli
00000010  62:5f:31:2e:30:20:28:6f:70:65:6e:73:73:6c:2c:20  b_1.0 (openssl, 
00000020  67:6d:70:29:0d:0a                                gmp)..

-> NET_SSH2_MSG_KEXINIT (since last: 0.1796, network: 0s)
00000000  d8:18:e9:65:85:2a:0e:6c:0c:3d:be:0b:b7:89:94:92  ...e.*.l.=......
00000010  00:00:00:7e:64:69:66:66:69:65:2d:68:65:6c:6c:6d  ...~diffie-hellm
00000020  61:6e:2d:67:72:6f:75:70:31:2d:73:68:61:31:2c:64  an-group1-sha1,d
00000030  69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72  iffie-hellman-gr
00000040  6f:75:70:31:34:2d:73:68:61:31:2c:64:69:66:66:69  oup14-sha1,diffi
00000050  65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:2d  e-hellman-group-
00000060  65:78:63:68:61:6e:67:65:2d:73:68:61:31:2c:64:69  exchange-sha1,di
00000070  66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f  ffie-hellman-gro
00000080  75:70:2d:65:78:63:68:61:6e:67:65:2d:73:68:61:32  up-exchange-sha2
00000090  35:36:00:00:00:29:72:73:61:2d:73:68:61:32:2d:32  56...)rsa-sha2-2
000000a0  35:36:2c:72:73:61:2d:73:68:61:32:2d:35:31:32:2c  56,rsa-sha2-512,
000000b0  73:73:68:2d:72:73:61:2c:73:73:68:2d:64:73:73:00  ssh-rsa,ssh-dss.
000000c0  00:00:00:00:00:00:00:00:00:00:39:68:6d:61:63:2d  ..........9hmac-
000000d0  73:68:61:32:2d:32:35:36:2c:68:6d:61:63:2d:73:68  sha2-256,hmac-sh
000000e0  61:31:2d:39:36:2c:68:6d:61:63:2d:73:68:61:31:2c  a1-96,hmac-sha1,
000000f0  68:6d:61:63:2d:6d:64:35:2d:39:36:2c:68:6d:61:63  hmac-md5-96,hmac
00000100  2d:6d:64:35:00:00:00:39:68:6d:61:63:2d:73:68:61  -md5...9hmac-sha
00000110  32:2d:32:35:36:2c:68:6d:61:63:2d:73:68:61:31:2d  2-256,hmac-sha1-
00000120  39:36:2c:68:6d:61:63:2d:73:68:61:31:2c:68:6d:61  96,hmac-sha1,hma
00000130  63:2d:6d:64:35:2d:39:36:2c:68:6d:61:63:2d:6d:64  c-md5-96,hmac-md
00000140  35:00:00:00:04:6e:6f:6e:65:00:00:00:04:6e:6f:6e  5....none....non
00000150  65:00:00:00:00:00:00:00:00:00:00:00:00:00        e.............

Thanks you for your help. Regards.

1 Answer 1

1

It looks like you're using phpseclib 1.0. As such you need to set the include_path, like so:

set_include_path(get_include_path() . PATH_SEPARATOR . 'lib');

phpseclib builds the list of encryption algorithms that it supports for SSH2 based on what can be loaded or auto-loaded. In your case it's not finding any encryption algorithms, suggesting that none are able to be loaded / auto-loaded. Presumably because of your include_path issues.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, it was an include problem. Fixed now, thanks you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.