Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined offset: 1 #1880

Open
BenasPaulikas opened this issue Feb 2, 2023 · 12 comments
Open

Undefined offset: 1 #1880

BenasPaulikas opened this issue Feb 2, 2023 · 12 comments
Labels

Comments

@BenasPaulikas
Copy link

BenasPaulikas commented Feb 2, 2023

Hey there. I'm getting this error from one of the linux machine only.
Happens on this line:
https://github.com/phpseclib/phpseclib/blob/3.0/phpseclib/Net/SSH2.php#L4328

Undefined offset: 1
#0 /var/www/foobar/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(4328): yii\base\ErrorHandler->handleError()
#1 /var/www/foobar/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(3831): phpseclib3\Net\SSH2->close_channel()
#2 /var/www/foobar/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php(2747): phpseclib3\Net\SSH2->get_channel_packet()
#3 /var/www/foobar/common/components/SSH2.php(71): phpseclib3\Net\SSH2->exec()

Any help would be highly appreciated.

@BenasPaulikas BenasPaulikas changed the title https://github.com/phpseclib/phpseclib Undefined offset: 1 Feb 2, 2023
@terrafrost
Copy link
Member

Can you get me the SSH logs? You can get them by doing define('NET_SSH2_LOGGING', 2) at the top of your file and then echo $ssh->getLog() after you encounter the error.

Thanks!

@BenasPaulikas
Copy link
Author

Attaching SSH log right after Undefined offset: 1 error

<-
00000000  53:53:48:2d:32:2e:30:2d:4f:70:65:6e:53:53:48:5f  SSH-2.0-OpenSSH_
00000010  38:2e:39:70:31:20:55:62:75:6e:74:75:2d:33:0d:0a  8.9p1 Ubuntu-3..

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

-> NET_SSH2_MSG_KEXINIT (since last: 0.2372, network: 0s)
00000000  f6:f4:ec:7e:23:5e:d1:23:48:bc:95:63:05:48:b5:42  ...~#^.#H..c.H.B
00000010  00:00:01:7c:63:75:72:76:65:32:35:35:31:39:2d:73  ...|curve25519-s
00000020  68:61:32:35:36:2c:63:75:72:76:65:32:35:35:31:39  ha256,curve25519
00000030  2d:73:68:61:32:35:36:40:6c:69:62:73:73:68:2e:6f  -sha256@libssh.o
00000040  72:67:2c:65:63:64:68:2d:73:68:61:32:2d:6e:69:73  rg,ecdh-sha2-nis
00000050  74:70:32:35:36:2c:65:63:64:68:2d:73:68:61:32:2d  tp256,ecdh-sha2-
00000060  6e:69:73:74:70:33:38:34:2c:65:63:64:68:2d:73:68  nistp384,ecdh-sh
00000070  61:32:2d:6e:69:73:74:70:35:32:31:2c:64:69:66:66  a2-nistp521,diff
00000080  69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70  ie-hellman-group
00000090  2d:65:78:63:68:61:6e:67:65:2d:73:68:61:32:35:36  -exchange-sha256
000000a0  2c:64:69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d  ,diffie-hellman-
000000b0  67:72:6f:75:70:2d:65:78:63:68:61:6e:67:65:2d:73  group-exchange-s
000000c0  68:61:31:2c:64:69:66:66:69:65:2d:68:65:6c:6c:6d  ha1,diffie-hellm
000000d0  61:6e:2d:67:72:6f:75:70:31:34:2d:73:68:61:32:35  an-group14-sha25
000000e0  36:2c:64:69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e  6,diffie-hellman
000000f0  2d:67:72:6f:75:70:31:34:2d:73:68:61:31:2c:64:69  -group14-sha1,di
00000100  66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f  ffie-hellman-gro
00000110  75:70:31:35:2d:73:68:61:35:31:32:2c:64:69:66:66  up15-sha512,diff
00000120  69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70  ie-hellman-group
00000130  31:36:2d:73:68:61:35:31:32:2c:64:69:66:66:69:65  16-sha512,diffie
00000140  2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:31:37  -hellman-group17
00000150  2d:73:68:61:35:31:32:2c:64:69:66:66:69:65:2d:68  -sha512,diffie-h
00000160  65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:31:38:2d:73  ellman-group18-s
00000170  68:61:35:31:32:2c:64:69:66:66:69:65:2d:68:65:6c  ha512,diffie-hel
00000180  6c:6d:61:6e:2d:67:72:6f:75:70:31:2d:73:68:61:31  lman-group1-sha1
00000190  00:00:00:71:73:73:68:2d:65:64:32:35:35:31:39:2c  ...qssh-ed25519,
000001a0  65:63:64:73:61:2d:73:68:61:32:2d:6e:69:73:74:70  ecdsa-sha2-nistp
000001b0  32:35:36:2c:65:63:64:73:61:2d:73:68:61:32:2d:6e  256,ecdsa-sha2-n
000001c0  69:73:74:70:33:38:34:2c:65:63:64:73:61:2d:73:68  istp384,ecdsa-sh
000001d0  61:32:2d:6e:69:73:74:70:35:32:31:2c:72:73:61:2d  a2-nistp521,rsa-
000001e0  73:68:61:32:2d:32:35:36:2c:72:73:61:2d:73:68:61  sha2-256,rsa-sha
000001f0  32:2d:35:31:32:2c:73:73:68:2d:72:73:61:2c:73:73  2-512,ssh-rsa,ss
00000200  68:2d:64:73:73:00:00:01:01:61:65:73:32:35:36:2d  h-dss....aes256-
00000210  67:63:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c  gcm@openssh.com,
00000220  61:65:73:31:32:38:2d:67:63:6d:40:6f:70:65:6e:73  aes128-gcm@opens
00000230  73:68:2e:63:6f:6d:2c:61:65:73:31:32:38:2d:63:74  sh.com,aes128-ct
00000240  72:2c:61:65:73:31:39:32:2d:63:74:72:2c:61:65:73  r,aes192-ctr,aes
00000250  32:35:36:2d:63:74:72:2c:61:65:73:31:32:38:2d:63  256-ctr,aes128-c
00000260  62:63:2c:61:65:73:31:39:32:2d:63:62:63:2c:61:65  bc,aes192-cbc,ae
00000270  73:32:35:36:2d:63:62:63:2c:62:6c:6f:77:66:69:73  s256-cbc,blowfis
00000280  68:2d:63:74:72:2c:62:6c:6f:77:66:69:73:68:2d:63  h-ctr,blowfish-c
00000290  62:63:2c:33:64:65:73:2d:63:74:72:2c:33:64:65:73  bc,3des-ctr,3des
000002a0  2d:63:62:63:2c:74:77:6f:66:69:73:68:31:32:38:2d  -cbc,twofish128-
000002b0  63:74:72:2c:74:77:6f:66:69:73:68:31:39:32:2d:63  ctr,twofish192-c
000002c0  74:72:2c:74:77:6f:66:69:73:68:32:35:36:2d:63:74  tr,twofish256-ct
000002d0  72:2c:74:77:6f:66:69:73:68:31:32:38:2d:63:62:63  r,twofish128-cbc
000002e0  2c:74:77:6f:66:69:73:68:31:39:32:2d:63:62:63:2c  ,twofish192-cbc,
000002f0  74:77:6f:66:69:73:68:32:35:36:2d:63:62:63:2c:74  twofish256-cbc,t
00000300  77:6f:66:69:73:68:2d:63:62:63:00:00:01:01:61:65  wofish-cbc....ae
00000310  73:32:35:36:2d:67:63:6d:40:6f:70:65:6e:73:73:68  s256-gcm@openssh
00000320  2e:63:6f:6d:2c:61:65:73:31:32:38:2d:67:63:6d:40  .com,aes128-gcm@
00000330  6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:61:65:73:31  openssh.com,aes1
00000340  32:38:2d:63:74:72:2c:61:65:73:31:39:32:2d:63:74  28-ctr,aes192-ct
00000350  72:2c:61:65:73:32:35:36:2d:63:74:72:2c:61:65:73  r,aes256-ctr,aes
00000360  31:32:38:2d:63:62:63:2c:61:65:73:31:39:32:2d:63  128-cbc,aes192-c
00000370  62:63:2c:61:65:73:32:35:36:2d:63:62:63:2c:62:6c  bc,aes256-cbc,bl
00000380  6f:77:66:69:73:68:2d:63:74:72:2c:62:6c:6f:77:66  owfish-ctr,blowf
00000390  69:73:68:2d:63:62:63:2c:33:64:65:73:2d:63:74:72  ish-cbc,3des-ctr
000003a0  2c:33:64:65:73:2d:63:62:63:2c:74:77:6f:66:69:73  ,3des-cbc,twofis
000003b0  68:31:32:38:2d:63:74:72:2c:74:77:6f:66:69:73:68  h128-ctr,twofish
000003c0  31:39:32:2d:63:74:72:2c:74:77:6f:66:69:73:68:32  192-ctr,twofish2
000003d0  35:36:2d:63:74:72:2c:74:77:6f:66:69:73:68:31:32  56-ctr,twofish12
000003e0  38:2d:63:62:63:2c:74:77:6f:66:69:73:68:31:39:32  8-cbc,twofish192
000003f0  2d:63:62:63:2c:74:77:6f:66:69:73:68:32:35:36:2d  -cbc,twofish256-
00000400  63:62:63:2c:74:77:6f:66:69:73:68:2d:63:62:63:00  cbc,twofish-cbc.
00000410  00:00:f7:68:6d:61:63:2d:73:68:61:32:2d:32:35:36  ...hmac-sha2-256
00000420  2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d  -etm@openssh.com
00000430  2c:68:6d:61:63:2d:73:68:61:32:2d:35:31:32:2d:65  ,hmac-sha2-512-e
00000440  74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:75  tm@openssh.com,u
00000450  6d:61:63:2d:36:34:2d:65:74:6d:40:6f:70:65:6e:73  mac-64-etm@opens
00000460  73:68:2e:63:6f:6d:2c:75:6d:61:63:2d:31:32:38:2d  sh.com,umac-128-
00000470  65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c  etm@openssh.com,
00000480  68:6d:61:63:2d:73:68:61:31:2d:65:74:6d:40:6f:70  hmac-sha1-etm@op
00000490  65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:73  enssh.com,hmac-s
000004a0  68:61:32:2d:32:35:36:2c:68:6d:61:63:2d:73:68:61  ha2-256,hmac-sha
000004b0  32:2d:35:31:32:2c:75:6d:61:63:2d:36:34:40:6f:70  2-512,umac-64@op
000004c0  65:6e:73:73:68:2e:63:6f:6d:2c:75:6d:61:63:2d:31  enssh.com,umac-1
000004d0  32:38:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68  28@openssh.com,h
000004e0  6d:61:63:2d:73:68:61:31:2d:39:36:2c:68:6d:61:63  mac-sha1-96,hmac
000004f0  2d:73:68:61:31:2c:68:6d:61:63:2d:6d:64:35:2d:39  -sha1,hmac-md5-9
00000500  36:2c:68:6d:61:63:2d:6d:64:35:00:00:00:f7:68:6d  6,hmac-md5....hm
00000510  61:63:2d:73:68:61:32:2d:32:35:36:2d:65:74:6d:40  ac-sha2-256-etm@
00000520  6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63  openssh.com,hmac
00000530  2d:73:68:61:32:2d:35:31:32:2d:65:74:6d:40:6f:70  -sha2-512-etm@op
00000540  65:6e:73:73:68:2e:63:6f:6d:2c:75:6d:61:63:2d:36  enssh.com,umac-6
00000550  34:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f  4-etm@openssh.co
00000560  6d:2c:75:6d:61:63:2d:31:32:38:2d:65:74:6d:40:6f  m,umac-128-etm@o
00000570  70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d  penssh.com,hmac-
00000580  73:68:61:31:2d:65:74:6d:40:6f:70:65:6e:73:73:68  sha1-etm@openssh
00000590  2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61:32:2d:32  .com,hmac-sha2-2
000005a0  35:36:2c:68:6d:61:63:2d:73:68:61:32:2d:35:31:32  56,hmac-sha2-512
000005b0  2c:75:6d:61:63:2d:36:34:40:6f:70:65:6e:73:73:68  ,umac-64@openssh
000005c0  2e:63:6f:6d:2c:75:6d:61:63:2d:31:32:38:40:6f:70  .com,umac-128@op
000005d0  65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:73  enssh.com,hmac-s
000005e0  68:61:31:2d:39:36:2c:68:6d:61:63:2d:73:68:61:31  ha1-96,hmac-sha1
000005f0  2c:68:6d:61:63:2d:6d:64:35:2d:39:36:2c:68:6d:61  ,hmac-md5-96,hma
00000600  63:2d:6d:64:35:00:00:00:1a:6e:6f:6e:65:2c:7a:6c  c-md5....none,zl
00000610  69:62:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:7a  ib@openssh.com,z
00000620  6c:69:62:00:00:00:1a:6e:6f:6e:65:2c:7a:6c:69:62  lib....none,zlib
00000630  40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:7a:6c:69  @openssh.com,zli
00000640  62:00:00:00:00:00:00:00:00:00:00:00:00:00        b.............

<- NET_SSH2_MSG_KEXINIT (since last: 0.1124, network: 0.1124s)
00000000  c9:f4:35:8d:f5:1d:9b:2b:0f:bb:5a:70:1a:08:6f:06  ..5....+..Zp..o.
00000010  00:00:01:09:63:75:72:76:65:32:35:35:31:39:2d:73  ....curve25519-s
00000020  68:61:32:35:36:2c:63:75:72:76:65:32:35:35:31:39  ha256,curve25519
00000030  2d:73:68:61:32:35:36:40:6c:69:62:73:73:68:2e:6f  -sha256@libssh.o
00000040  72:67:2c:65:63:64:68:2d:73:68:61:32:2d:6e:69:73  rg,ecdh-sha2-nis
00000050  74:70:32:35:36:2c:65:63:64:68:2d:73:68:61:32:2d  tp256,ecdh-sha2-
00000060  6e:69:73:74:70:33:38:34:2c:65:63:64:68:2d:73:68  nistp384,ecdh-sh
00000070  61:32:2d:6e:69:73:74:70:35:32:31:2c:73:6e:74:72  a2-nistp521,sntr
00000080  75:70:37:36:31:78:32:35:35:31:39:2d:73:68:61:35  up761x25519-sha5
00000090  31:32:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:64  12@openssh.com,d
000000a0  69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72  iffie-hellman-gr
000000b0  6f:75:70:2d:65:78:63:68:61:6e:67:65:2d:73:68:61  oup-exchange-sha
000000c0  32:35:36:2c:64:69:66:66:69:65:2d:68:65:6c:6c:6d  256,diffie-hellm
000000d0  61:6e:2d:67:72:6f:75:70:31:36:2d:73:68:61:35:31  an-group16-sha51
000000e0  32:2c:64:69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e  2,diffie-hellman
000000f0  2d:67:72:6f:75:70:31:38:2d:73:68:61:35:31:32:2c  -group18-sha512,
00000100  64:69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67  diffie-hellman-g
00000110  72:6f:75:70:31:34:2d:73:68:61:32:35:36:00:00:00  roup14-sha256...
00000120  39:72:73:61:2d:73:68:61:32:2d:35:31:32:2c:72:73  9rsa-sha2-512,rs
00000130  61:2d:73:68:61:32:2d:32:35:36:2c:65:63:64:73:61  a-sha2-256,ecdsa
00000140  2d:73:68:61:32:2d:6e:69:73:74:70:32:35:36:2c:73  -sha2-nistp256,s
00000150  73:68:2d:65:64:32:35:35:31:39:00:00:00:6c:63:68  sh-ed25519...lch
00000160  61:63:68:61:32:30:2d:70:6f:6c:79:31:33:30:35:40  acha20-poly1305@
00000170  6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:61:65:73:31  openssh.com,aes1
00000180  32:38:2d:63:74:72:2c:61:65:73:31:39:32:2d:63:74  28-ctr,aes192-ct
00000190  72:2c:61:65:73:32:35:36:2d:63:74:72:2c:61:65:73  r,aes256-ctr,aes
000001a0  31:32:38:2d:67:63:6d:40:6f:70:65:6e:73:73:68:2e  128-gcm@openssh.
000001b0  63:6f:6d:2c:61:65:73:32:35:36:2d:67:63:6d:40:6f  com,aes256-gcm@o
000001c0  70:65:6e:73:73:68:2e:63:6f:6d:00:00:00:6c:63:68  penssh.com...lch
000001d0  61:63:68:61:32:30:2d:70:6f:6c:79:31:33:30:35:40  acha20-poly1305@
000001e0  6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:61:65:73:31  openssh.com,aes1
000001f0  32:38:2d:63:74:72:2c:61:65:73:31:39:32:2d:63:74  28-ctr,aes192-ct
00000200  72:2c:61:65:73:32:35:36:2d:63:74:72:2c:61:65:73  r,aes256-ctr,aes
00000210  31:32:38:2d:67:63:6d:40:6f:70:65:6e:73:73:68:2e  128-gcm@openssh.
00000220  63:6f:6d:2c:61:65:73:32:35:36:2d:67:63:6d:40:6f  com,aes256-gcm@o
00000230  70:65:6e:73:73:68:2e:63:6f:6d:00:00:00:d5:75:6d  penssh.com....um
00000240  61:63:2d:36:34:2d:65:74:6d:40:6f:70:65:6e:73:73  ac-64-etm@openss
00000250  68:2e:63:6f:6d:2c:75:6d:61:63:2d:31:32:38:2d:65  h.com,umac-128-e
00000260  74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68  tm@openssh.com,h
00000270  6d:61:63:2d:73:68:61:32:2d:32:35:36:2d:65:74:6d  mac-sha2-256-etm
00000280  40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61  @openssh.com,hma
00000290  63:2d:73:68:61:32:2d:35:31:32:2d:65:74:6d:40:6f  c-sha2-512-etm@o
000002a0  70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d  penssh.com,hmac-
000002b0  73:68:61:31:2d:65:74:6d:40:6f:70:65:6e:73:73:68  sha1-etm@openssh
000002c0  2e:63:6f:6d:2c:75:6d:61:63:2d:36:34:40:6f:70:65  .com,umac-64@ope
000002d0  6e:73:73:68:2e:63:6f:6d:2c:75:6d:61:63:2d:31:32  nssh.com,umac-12
000002e0  38:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d  8@openssh.com,hm
000002f0  61:63:2d:73:68:61:32:2d:32:35:36:2c:68:6d:61:63  ac-sha2-256,hmac
00000300  2d:73:68:61:32:2d:35:31:32:2c:68:6d:61:63:2d:73  -sha2-512,hmac-s
00000310  68:61:31:00:00:00:d5:75:6d:61:63:2d:36:34:2d:65  ha1....umac-64-e
00000320  74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:75  tm@openssh.com,u
00000330  6d:61:63:2d:31:32:38:2d:65:74:6d:40:6f:70:65:6e  mac-128-etm@open
00000340  73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61  ssh.com,hmac-sha
00000350  32:2d:32:35:36:2d:65:74:6d:40:6f:70:65:6e:73:73  2-256-etm@openss
00000360  68:2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61:32:2d  h.com,hmac-sha2-
00000370  35:31:32:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e  512-etm@openssh.
00000380  63:6f:6d:2c:68:6d:61:63:2d:73:68:61:31:2d:65:74  com,hmac-sha1-et
00000390  6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:75:6d  m@openssh.com,um
000003a0  61:63:2d:36:34:40:6f:70:65:6e:73:73:68:2e:63:6f  ac-64@openssh.co
000003b0  6d:2c:75:6d:61:63:2d:31:32:38:40:6f:70:65:6e:73  m,umac-128@opens
000003c0  73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61:32  sh.com,hmac-sha2
000003d0  2d:32:35:36:2c:68:6d:61:63:2d:73:68:61:32:2d:35  -256,hmac-sha2-5
000003e0  31:32:2c:68:6d:61:63:2d:73:68:61:31:00:00:00:15  12,hmac-sha1....
000003f0  6e:6f:6e:65:2c:7a:6c:69:62:40:6f:70:65:6e:73:73  none,zlib@openss
00000400  68:2e:63:6f:6d:00:00:00:15:6e:6f:6e:65:2c:7a:6c  h.com....none,zl
00000410  69:62:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:00:00  ib@openssh.com..
00000420  00:00:00:00:00:00:00:00:00:00:00                 ...........

-> NET_SSH2_MSG_KEX_ECDH_INIT (since last: 0.0005, network: 0s)
00000000  00:00:00:20:6e:a4:2f:fc:61:35:20:91:43:48:f1:1c  ... n./.a5 .CH..
00000010  26:43:f4:9d:cd:d3:de:b0:57:f7:a9:76:9a:7c:a0:63  &C......W..v.|.c
00000020  ad:eb:10:62                                      ...b

<- NET_SSH2_MSG_KEX_ECDH_REPLY (since last: 0.1185, network: 0.1185s)
00000000  00:00:00:33:00:00:00:0b:73:73:68:2d:65:64:32:35  ...3....ssh-ed25
00000010  35:31:39:00:00:00:20:42:e7:59:55:bc:26:b2:35:b9  519... B.YU.&.5.
00000020  c1:20:5a:59:40:59:85:ed:1d:c4:c7:31:7f:ee:0b:d7  . ZY@Y.....1....
00000030  11:6f:a6:a2:c1:6c:be:00:00:00:20:ea:5f:f9:58:8c  .o...l.... ._.X.
00000040  ae:03:29:7f:37:83:bb:a4:92:21:bc:b0:cd:32:63:a1  ..).7....!...2c.
00000050  ef:38:53:b9:e3:d4:0d:d9:ed:d6:4d:00:00:00:53:00  .8S.......M...S.
00000060  00:00:0b:73:73:68:2d:65:64:32:35:35:31:39:00:00  ...ssh-ed25519..
00000070  00:40:64:fa:ee:9b:33:51:99:90:b8:db:e1:d8:ef:92  .@d...3Q........
00000080  94:d7:04:de:bc:fe:8b:4d:cb:01:46:eb:60:0d:f5:72  .......M..F.`..r
00000090  c1:1b:60:7f:a1:15:b9:79:b9:fc:c1:e9:c1:fa:bc:1a  ..`....y........
000000a0  65:bf:83:65:6f:85:bb:7e:10:d0:0c:af:9d:19:6b:5f  e..eo..~......k_
000000b0  eb:0d                                            ..

-> NET_SSH2_MSG_NEWKEYS (since last: 0.0002, network: 0s)
                                                 

<- NET_SSH2_MSG_NEWKEYS (since last: 0, network: 0s)
                                                 

-> NET_SSH2_MSG_SERVICE_REQUEST (since last: 0.0002, network: 0s)
00000000  00:00:00:0c:73:73:68:2d:75:73:65:72:61:75:74:68  ....ssh-userauth

<- NET_SSH2_MSG_SERVICE_ACCEPT (since last: 0.2671, network: 0.2671s)
00000000  00:00:00:0c:73:73:68:2d:75:73:65:72:61:75:74:68  ....ssh-userauth

-> NET_SSH2_MSG_USERAUTH_REQUEST (since last: 0.0001, network: 0s)
00000000  00:00:00:04:72:6f:6f:74:00:00:00:0e:73:73:68:2d  ....root....ssh-
00000010  63:6f:6e:6e:65:63:74:69:6f:6e:00:00:00:04:6e:6f  connection....no
00000020  6e:65                                            ne

<- NET_SSH2_MSG_USERAUTH_FAILURE (since last: 0.1204, network: 0.1204s)
00000000  00:00:00:12:70:75:62:6c:69:63:6b:65:79:2c:70:61  ....publickey,pa
00000010  73:73:77:6f:72:64:00                             ssword.

-> NET_SSH2_MSG_USERAUTH_REQUEST (since last: 0.0001, network: 0s)
00000000  00:00:00:04:72:6f:6f:74:00:00:00:0e:73:73:68:2d  ....root....ssh-
00000010  63:6f:6e:6e:65:63:74:69:6f:6e:00:00:00:08:70:61  connection....pa
00000020  73:73:77:6f:72:64:00:00:00:00:08:70:61:73:73:77  ssword.....passw
00000030  6f:72:64                                         ord

<- NET_SSH2_MSG_USERAUTH_SUCCESS (since last: 0.1676, network: 0.1675s)
                                                 

-> NET_SSH2_MSG_CHANNEL_OPEN (since last: 0.0003, network: 0s)
00000000  00:00:00:07:73:65:73:73:69:6f:6e:00:00:00:01:7f  ....session.....
00000010  ff:ff:ff:00:00:40:00                             .....@.

@BenasPaulikas
Copy link
Author

I also have to mention that this is long running script. However it produces this error only for 1 out many linux boxes.

@terrafrost
Copy link
Member

Out of curiosity, what does echo $ssh->isTimeout() ? 'y' : 'n' give you? I'm guessing that it's gonna output "y". If so then the reason you're getting that error is because the server never sent the appropriate response, in time. Like it's reasonable that you get an error altho it might be useful if the error were more useful.

I created a branch on my own fork of the phpseclib repo that makes the error message a little more useful here:

terrafrost@4a79a24

That said, assuming that this is all correct then you should probably look at the server logs. Like enable verbose logging on the server and see what the server logs are saying. Normally I do that by doing sudo /usr/sbin/sshd -ddd -p2222 but who knows if you have that level of access to the SSH server

@BenasPaulikas
Copy link
Author

@terrafrost ty for reply. Yes you are right it's a timeout and execution maches setTimeout($seconds)
Do I understand correctly that this errors means connection failed to be established during setTimeout($seconds) ?
And it's not related to long executed command?

@terrafrost
Copy link
Member

Do I understand correctly that this errors means connection failed to be established during setTimeout($seconds) ?
And it's not related to long executed command?

Correct. Per your logs it's timing out before phpseclib has even had a chance to send the command. So the way SSH2 works is... you, the client, open up a channel. Once the server confirms that the channel has been opened you, the client, send an "exec" channel request with the command you're wanting executed. The server isn't even responding with the confirmation that the channel has been opened so phpseclib is error'ing out before it would normally send the command.

@BenasPaulikas
Copy link
Author

Ok that makes sense. Anyways I don't care about error message anymore as I know what this means. Thank you for all the help

@BenasPaulikas
Copy link
Author

BenasPaulikas commented Feb 12, 2023

@terrafrost I used your suggestion and did sudo /usr/sbin/sshd -ddd -p2222 to get to the root of the problem.
Most of the requests are going out without any problems.
However this is the example where it's delaying 5 seconds (sometimes it's even more)
image

Do you have anything to suggest/recommend?
P.S. I might be wrong but for example when phpstorm OR phpseclib is timing out on connection. I try to do from my local terminal ssh root@IP and it works. Or this can't be true?

On top of that I can mention that I'm running
OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022 I also have another server with exactly same version and there's no such issues there.

@terrafrost
Copy link
Member

idk a ton about the internals of OpenSSH / Linux's PAM. I've posted your question on the openssh-unix-dev@mindrot.org mailing list to see if the people there might have some insights.

It could be interesting to see more of the logs as well. Like where it's opening the channel. The screenshot you posted is just showing the key exchange debug info. Like phpseclib, by default, will time out after 10s, so there's prob still some time consuming stuff going on outside of the screenshot that you sent.

@BenasPaulikas
Copy link
Author

@terrafrost thank you for helping out. It's super easy for me to reproduce this. I get same thing in max 20 tries.
https://pastebin.com/hnqdhnLn Here I'm attaching full sshd log from start to end.

@terrafrost
Copy link
Member

Haven't gotten any responses from my email yet but I did a Google search for debug3: PAM: sshpam_store_conv called with 1 messages and found this:

https://ubuntuforums.org/showthread.php?t=1448030&s=fc11356aef29997dd92695cf54b97c8d&p=10399729#post10399729

@BenasPaulikas
Copy link
Author

BenasPaulikas commented Feb 15, 2023

Hmm based on that thread
https://bugs.launchpad.net/ubuntu/+source/landscape-client/+bug/519930 - not this as I don't have remote mounts
UseDNS - already set to no
Not related to pam_ck_connector. I'm not using
GSSAPIAuthentication no - didn't helped
#session optional pam_systemd.so - didn't helped
I've also ran with strace and nothing around that hanging line.

I also have to mention that this hang-up takes exactly 9-10 seconds. And changing phpseclib timeout doesn't change anything.
On top of that when creating new SSH2 class I pass 2 seconds timeout. And it's not being respected. It still waits out all 9-10 seconds.

@bantu bantu added the support label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants