phpseclib SFTP用户身份验证失败

问题描述 投票:0回答:1

我正在尝试通过使用phpseclib在laravel 5.7框架上运行的Web应用程序测试SFTP连接。这是验证码,仅使用密码验证。 SFTP服务器还使用IP白名单作为附加安全性。

                $sftp = new SFTP(env('SFTP_HOST'));
                if (!$sftp->login(env('SFTP_USER'), env('SFTP_PASSWORD'))) {
                    echo $sftp->getLog();
                }

以及结果日志

<-
00000000  53:53:48:2d:32:2e:30:2d:53:53:48:44:0d:0a        SSH-2.0-SSHD..

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

-> NET_SSH2_MSG_KEXINIT (since last: 0.0826, network: 0.0001s)
00000000  74:b6:6e:1a:43:0f:ca:34:93:5d:3e:97:4f:ae:80:0d  t.n.C..4.]>.O...
00000010  00:00:00:9b:63:75:72:76:65:32:35:35:31:39:2d:73  ....curve25519-s
00000020  68:61:32:35:36:40:6c:69:62:73:73:68:2e:6f:72:67  [email protected]
00000030  2c:64:69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d  ,diffie-hellman-
00000040  67:72:6f:75:70:2d:65:78:63:68:61:6e:67:65:2d:73  group-exchange-s
00000050  68:61:32:35:36:2c:64:69:66:66:69:65:2d:68:65:6c  ha256,diffie-hel
00000060  6c:6d:61:6e:2d:67:72:6f:75:70:2d:65:78:63:68:61  lman-group-excha
00000070  6e:67:65:2d:73:68:61:31:2c:64:69:66:66:69:65:2d  nge-sha1,diffie-
00000080  68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:31:34:2d  hellman-group14-
00000090  73:68:61:31:2c:64:69:66:66:69:65:2d:68:65:6c:6c  sha1,diffie-hell
000000a0  6d:61:6e:2d:67:72:6f:75:70:31:2d:73:68:61:31:00  man-group1-sha1.
000000b0  00:00:29:72:73:61:2d:73:68:61:32:2d:32:35:36:2c  ..)rsa-sha2-256,
000000c0  72:73:61:2d:73:68:61:32:2d:35:31:32:2c:73:73:68  rsa-sha2-512,ssh
000000d0  2d:72:73:61:2c:73:73:68:2d:64:73:73:00:00:00:ff  -rsa,ssh-dss....
000000e0  61:65:73:31:32:38:2d:63:74:72:2c:61:65:73:31:39  aes128-ctr,aes19
000000f0  32:2d:63:74:72:2c:61:65:73:32:35:36:2d:63:74:72  2-ctr,aes256-ctr
00000100  2c:61:65:73:31:32:38:2d:63:62:63:2c:61:65:73:31  ,aes128-cbc,aes1
00000110  39:32:2d:63:62:63:2c:61:65:73:32:35:36:2d:63:62  92-cbc,aes256-cb
00000120  63:2c:62:6c:6f:77:66:69:73:68:2d:63:74:72:2c:62  c,blowfish-ctr,b
00000130  6c:6f:77:66:69:73:68:2d:63:62:63:2c:33:64:65:73  lowfish-cbc,3des
00000140  2d:63:74:72:2c:33:64:65:73:2d:63:62:63:2c:61:72  -ctr,3des-cbc,ar
00000150  63:66:6f:75:72:32:35:36:2c:61:72:63:66:6f:75:72  cfour256,arcfour
00000160  32:35:36:2c:61:72:63:66:6f:75:72:31:32:38:2c:61  256,arcfour128,a
00000170  72:63:66:6f:75:72:31:32:38:2c:74:77:6f:66:69:73  rcfour128,twofis
00000180  68:31:32:38:2d:63:74:72:2c:74:77:6f:66:69:73:68  h128-ctr,twofish
00000190  31:39:32:2d:63:74:72:2c:74:77:6f:66:69:73:68:32  192-ctr,twofish2
000001a0  35:36:2d:63:74:72:2c:74:77:6f:66:69:73:68:31:32  56-ctr,twofish12
000001b0  38:2d:63:62:63:2c:74:77:6f:66:69:73:68:31:39:32  8-cbc,twofish192
000001c0  2d:63:62:63:2c:74:77:6f:66:69:73:68:32:35:36:2d  -cbc,twofish256-
000001d0  63:62:63:2c:74:77:6f:66:69:73:68:2d:63:62:63:00  cbc,twofish-cbc.
000001e0  00:00:ff:61:65:73:31:32:38:2d:63:74:72:2c:61:65  ...aes128-ctr,ae
000001f0  73:31:39:32:2d:63:74:72:2c:61:65:73:32:35:36:2d  s192-ctr,aes256-
00000200  63:74:72:2c:61:65:73:31:32:38:2d:63:62:63:2c:61  ctr,aes128-cbc,a
00000210  65:73:31:39:32:2d:63:62:63:2c:61:65:73:32:35:36  es192-cbc,aes256
00000220  2d:63:62:63:2c:62:6c:6f:77:66:69:73:68:2d:63:74  -cbc,blowfish-ct
00000230  72:2c:62:6c:6f:77:66:69:73:68:2d:63:62:63:2c:33  r,blowfish-cbc,3
00000240  64:65:73:2d:63:74:72:2c:33:64:65:73:2d:63:62:63  des-ctr,3des-cbc
00000250  2c:61:72:63:66:6f:75:72:32:35:36:2c:61:72:63:66  ,arcfour256,arcf
00000260  6f:75:72:32:35:36:2c:61:72:63:66:6f:75:72:31:32  our256,arcfour12
00000270  38:2c:61:72:63:66:6f:75:72:31:32:38:2c:74:77:6f  8,arcfour128,two
00000280  66:69:73:68:31:32:38:2d:63:74:72:2c:74:77:6f:66  fish128-ctr,twof
00000290  69:73:68:31:39:32:2d:63:74:72:2c:74:77:6f:66:69  ish192-ctr,twofi
000002a0  73:68:32:35:36:2d:63:74:72:2c:74:77:6f:66:69:73  sh256-ctr,twofis
000002b0  68:31:32:38:2d:63:62:63:2c:74:77:6f:66:69:73:68  h128-cbc,twofish
000002c0  31:39:32:2d:63:62:63:2c:74:77:6f:66:69:73:68:32  192-cbc,twofish2
000002d0  35:36:2d:63:62:63:2c:74:77:6f:66:69:73:68:2d:63  56-cbc,twofish-c
000002e0  62:63:00:00:00:20:68:6d:61:63:2d:73:68:61:32:2d  bc... hmac-sha2-
000002f0  32:35:36:2c:68:6d:61:63:2d:73:68:61:31:2c:68:6d  256,hmac-sha1,hm
00000300  61:63:2d:6d:64:35:00:00:00:20:68:6d:61:63:2d:73  ac-md5... hmac-s
00000310  68:61:32:2d:32:35:36:2c:68:6d:61:63:2d:73:68:61  ha2-256,hmac-sha
00000320  31:2c:68:6d:61:63:2d:6d:64:35:00:00:00:04:6e:6f  1,hmac-md5....no
00000330  6e:65:00:00:00:04:6e:6f:6e:65:00:00:00:00:00:00  ne....none......
00000340  00:00:00:00:00:00:00                             .......

<- NET_SSH2_MSG_KEXINIT (since last: 0.0001, network: 0s)
00000000  a1:ee:4f:02:f6:7c:91:2c:a7:c3:8b:fe:70:b3:b2:f1  ..O..|.,....p...
00000010  00:00:00:40:64:69:66:66:69:65:2d:68:65:6c:6c:6d  ...@diffie-hellm
00000020  61:6e:2d:67:72:6f:75:70:31:34:2d:73:68:61:31:2c  an-group14-sha1,
00000030  64:69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67  diffie-hellman-g
00000040  72:6f:75:70:2d:65:78:63:68:61:6e:67:65:2d:73:68  roup-exchange-sh
00000050  61:32:35:36:00:00:00:07:73:73:68:2d:72:73:61:00  a256....ssh-rsa.
00000060  00:00:0a:61:65:73:32:35:36:2d:63:74:72:00:00:00  ...aes256-ctr...
00000070  0a:61:65:73:32:35:36:2d:63:74:72:00:00:00:15:68  .aes256-ctr....h
00000080  6d:61:63:2d:73:68:61:32:35:36:2c:68:6d:61:63:2d  mac-sha256,hmac-
00000090  73:68:61:31:00:00:00:15:68:6d:61:63:2d:73:68:61  sha1....hmac-sha
000000a0  32:35:36:2c:68:6d:61:63:2d:73:68:61:31:00:00:00  256,hmac-sha1...
000000b0  09:6e:6f:6e:65:2c:7a:6c:69:62:00:00:00:09:6e:6f  .none,zlib....no
000000c0  6e:65:2c:7a:6c:69:62:00:00:00:00:00:00:00:00:00  ne,zlib.........
000000d0  00:00:00:00                                      ....

-> UNKNOWN (34) (since last: 0.0001, network: 0s)
00000000  00:00:06:00:00:00:08:00:00:00:10:00              ............

<- NET_SSH2_MSG_KEXDH_REPLY (since last: 0.1209, network: 0.1209s)
00000000  00:00:01:01:00:ff:ff:ff:ff:ff:ff:ff:ff:c9:0f:da  ................
00000010  a2:21:68:c2:34:c4:c6:62:8b:80:dc:1c:d1:29:02:4e  .!h.4..b.....).N
00000020  08:8a:67:cc:74:02:0b:be:a6:3b:13:9b:22:51:4a:08  ..g.t....;.."QJ.
00000030  79:8e:34:04:dd:ef:95:19:b3:cd:3a:43:1b:30:2b:0a  y.4.......:C.0+.
00000040  6d:f2:5f:14:37:4f:e1:35:6d:6d:51:c2:45:e4:85:b5  m._.7O.5mmQ.E...
00000050  76:62:5e:7e:c6:f4:4c:42:e9:a6:37:ed:6b:0b:ff:5c  vb^~..LB..7.k..\
00000060  b6:f4:06:b7:ed:ee:38:6b:fb:5a:89:9f:a5:ae:9f:24  ......8k.Z.....$
00000070  11:7c:4b:1f:e6:49:28:66:51:ec:e4:5b:3d:c2:00:7c  .|K..I(fQ..[=..|
00000080  b8:a1:63:bf:05:98:da:48:36:1c:55:d3:9a:69:16:3f  ..c....H6.U..i.?
00000090  a8:fd:24:cf:5f:83:65:5d:23:dc:a3:ad:96:1c:62:f3  ..$._.e]#.....b.
000000a0  56:20:85:52:bb:9e:d5:29:07:70:96:96:6d:67:0c:35  V .R...).p..mg.5
000000b0  4e:4a:bc:98:04:f1:74:6c:08:ca:18:21:7c:32:90:5e  NJ....tl...!|2.^
000000c0  46:2e:36:ce:3b:e3:9e:77:2c:18:0e:86:03:9b:27:83  F.6.;..w,.....'.
000000d0  a2:ec:07:a2:8f:b5:c5:5d:f0:6f:4c:52:c9:de:2b:cb  .......].oLR..+.
000000e0  f6:95:58:17:18:39:95:49:7c:ea:95:6a:e5:15:d2:26  ..X..9.I|..j...&
000000f0  18:98:fa:05:10:15:72:8e:5a:8a:ac:aa:68:ff:ff:ff  ......r.Z...h...
00000100  ff:ff:ff:ff:ff:00:00:00:01:02                    ..........

-> UNKNOWN (32) (since last: 0.0257, network: 0.0001s)
00000000  00:00:01:01:00:97:89:5b:79:98:d3:54:10:e6:c9:3f  .......[y..T...?
00000010  1c:74:2b:fd:7e:7a:b1:17:b1:53:13:8c:61:7a:2a:88  .t+.~z...S..az*.
00000020  15:d5:ca:72:f0:5f:2b:9f:e6:0f:e9:85:08:eb:62:90  ...r._+.......b.
00000030  c6:6f:6c:1d:81:36:30:59:9f:c9:6b:af:46:05:dd:01  .ol..60Y..k.F...
00000040  62:83:eb:1c:63:6d:6b:af:be:b4:77:f7:51:a6:db:af  b...cmk...w.Q...
00000050  f9:5d:2d:8e:9d:91:99:8d:f7:4c:3b:b0:5f:80:c9:30  .]-......L;._..0
00000060  f8:9a:9f:f6:d9:ec:35:4a:a1:54:f6:5c:9e:02:51:12  ......5J.T.\..Q.
00000070  22:d5:49:7d:d1:42:b3:94:90:7f:07:7a:6f:4d:4b:e9  ".I}.B.....zoMK.
00000080  7e:00:d1:f6:46:64:bb:c0:da:5f:62:fa:5e:f6:51:3a  ~...Fd..._b.^.Q:
00000090  48:b5:0a:37:97:cc:46:c6:1a:ca:37:6a:a3:4b:83:20  H..7..F...7j.K. 
000000a0  9b:58:e4:5a:f8:e1:25:57:20:59:bc:30:6b:38:e0:65  .X.Z..%W Y.0k8.e
000000b0  58:b6:eb:52:8f:aa:39:23:9b:e3:26:9d:40:d6:8f:48  X..R..9#..&[email protected]
000000c0  83:27:fa:6c:a4:96:83:67:13:1b:c8:fd:77:5f:0f:a2  .'.l...g....w_..
000000d0  7e:e4:b0:9c:9b:11:99:ce:f2:ca:b3:36:de:da:b7:65  ~..........6...e
000000e0  d5:69:5a:75:29:b9:ae:e2:1b:e6:6d:8b:24:50:4a:43  .iZu).....m.$PJC
000000f0  ba:37:1a:7c:63:bf:d0:4b:03:73:bc:70:39:f2:47:c0  .7.|c..K.s.p9.G.
00000100  97:4e:eb:7d:ce                                   .N.}.

<- UNKNOWN (33) (since last: 0.0468, network: 0.0468s)
00000000  00:00:01:17:00:00:00:07:73:73:68:2d:72:73:61:00  ........ssh-rsa.
00000010  00:00:03:01:00:01:00:00:01:01:00:90:2f:5e:c2:1b  ............/^..
00000020  f8:a2:a4:b5:60:97:7a:9c:a9:a9:d5:81:7b:58:04:c3  ....`.z.....{X..
00000030  db:b8:d2:40:85:be:b5:ab:fd:e1:42:d2:a4:3c:d2:51  [email protected]
00000040  0e:c6:84:44:6a:6b:0f:84:97:7a:cf:dc:8b:06:8d:23  ...Djk...z.....#
00000050  5c:27:71:cd:f5:6c:4d:1e:82:13:6d:ab:e2:3d:31:7d  \'q..lM...m..=1}
00000060  a7:78:ea:fa:fd:e1:24:6b:29:bb:10:8d:8f:73:0b:a4  .x....$k)....s..
00000070  cc:9b:19:05:b4:18:d7:30:08:a8:47:75:cd:62:7f:99  .......0..Gu.b..
00000080  c0:de:f1:d6:a4:43:ef:83:2b:39:5d:10:fe:fb:f6:4a  .....C..+9]....J
00000090  61:68:b2:30:df:2f:d0:df:4d:1e:06:6e:64:33:6d:ca  ah.0./..M..nd3m.
000000a0  18:81:de:25:02:14:2a:ba:2b:b7:3f:d0:9a:aa:af:7e  ...%..*.+.?....~
000000b0  1c:bc:9e:3d:ea:c9:08:dc:22:6f:9b:94:c4:67:c3:7c  ...=...."o...g.|
000000c0  0a:72:56:9b:ec:5d:92:48:a1:c2:15:1a:ab:6f:69:3a  .rV..].H.....oi:
000000d0  5a:99:c1:fc:ed:47:84:6f:67:e5:46:75:4b:0e:e1:1e  Z....G.og.FuK...
000000e0  0c:90:a6:ba:c3:4f:24:05:8c:c6:a0:05:9f:ed:a4:26  .....O$........&
000000f0  71:99:a3:03:7e:5e:be:67:9d:74:a3:b9:ed:66:37:81  q...~^.g.t...f7.
00000100  e5:65:e9:c2:e9:37:94:0e:00:05:6e:92:9d:af:fb:a5  .e...7....n.....
00000110  b7:ee:ed:71:d8:1e:03:1b:1e:a3:91:00:00:01:01:00  ...q............
00000120  c9:f1:18:5e:a8:fb:99:65:d8:ef:41:50:75:4d:d6:d8  ...^...e..APuM..
00000130  36:e6:46:6a:bb:3b:9a:c5:04:7b:16:99:78:4c:08:4d  6.Fj.;...{..xL.M
00000140  2f:f9:cb:f7:bd:b8:cf:c6:8a:91:9b:4b:b2:3d:46:88  /..........K.=F.
00000150  ba:e3:13:4c:c8:3e:29:e3:11:51:25:78:88:7f:61:8d  ...L.>)..Q%x..a.
00000160  9e:dd:d6:91:98:d5:e7:5d:f5:1e:4b:b9:f2:9a:fa:28  .......]..K....(
00000170  70:20:ae:62:fd:4e:ca:5b:c7:f2:af:5d:71:c9:20:63  p .b.N.[...]q. c
00000180  70:65:8d:d1:06:8e:7f:77:24:16:84:d2:15:d0:33:6d  pe.....w$.....3m
00000190  cd:4d:52:c8:10:25:a5:79:5c:63:2b:ba:48:07:f7:61  .MR..%.y\c+.H..a
000001a0  71:c7:86:c2:53:24:de:33:d0:da:a1:87:aa:66:15:39  q...S$.3.....f.9
000001b0  17:4f:86:9b:6f:c7:31:78:e1:0c:36:51:1f:db:11:06  .O..o.1x..6Q....
000001c0  34:01:df:b1:c4:a6:90:0d:8f:05:9a:00:a5:c5:e5:e7  4...............
000001d0  6b:cb:23:15:b0:26:65:20:09:20:f8:d2:51:02:23:93  k.#..&e . ..Q.#.
000001e0  88:6c:a8:77:25:19:09:9a:65:92:bc:8d:57:33:c2:fa  .l.w%...e...W3..
000001f0  b2:f2:d9:2b:07:e4:7a:6a:57:b4:3e:74:bc:9f:fd:fe  ...+..zjW.>t....
00000200  2f:fe:a8:b5:5c:11:c5:70:61:72:8c:94:c7:08:64:11  /...\..par....d.
00000210  36:db:58:d2:42:97:af:7a:17:7c:16:3b:24:6f:c2:3c  6.X.B..z.|.;$o..
00000220  00:00:01:0f:00:00:00:07:73:73:68:2d:72:73:61:00  ........ssh-rsa.
00000230  00:01:00:79:ff:a5:66:64:0c:24:e6:5d:98:4a:a3:41  ...y..fd.$.].J.A
00000240  6e:b2:00:b7:f6:a8:f7:b9:55:3f:5e:9c:38:f1:5e:71  n.......U?^.8.^q
00000250  2b:f4:b6:ba:9c:9b:19:5c:c8:45:8b:98:35:03:28:b2  +......\.E..5.(.
00000260  d2:23:e4:2c:2f:2f:50:ab:ed:44:e3:c6:7c:61:57:55  .#.,//P..D..|aWU
00000270  97:1e:41:ac:6d:b0:ff:fd:04:e0:27:07:e8:87:b8:26  ..A.m.....'....&
00000280  ab:be:0f:77:24:fc:e0:7b:51:7e:4a:58:9a:73:77:5f  ...w$..{Q~JX.sw_
00000290  09:09:01:49:73:83:17:00:df:d2:e0:3f:45:51:8e:d0  ...Is......?EQ..
000002a0  dc:a9:52:e7:e5:a6:e3:6a:40:33:fe:75:8a:8c:16:04  [email protected]....
000002b0  91:05:7d:0f:cb:45:7e:76:4d:a1:2f:14:da:6f:e0:60  ..}..E~vM./..o.`
000002c0  a9:3a:84:75:ca:15:69:7e:a5:67:86:3d:a9:ec:63:ea  .:.u..i~.g.=..c.
000002d0  48:67:0c:0d:8c:61:30:02:5b:cc:0f:9a:29:20:6d:9e  Hg...a0.[...) m.
000002e0  53:0c:c0:e9:8c:54:d7:23:e5:c8:5e:67:ce:96:37:b5  S....T.#..^g..7.
000002f0  ae:ea:31:90:07:b0:fd:39:3f:9a:d6:2a:a5:2b:a7:3e  ..1....9?..*.+.>
00000300  18:84:77:4c:53:76:a8:54:c6:25:b3:f8:1e:65:b5:2e  ..wLSv.T.%...e..
00000310  a2:19:a2:ea:88:ab:84:5a:1e:0a:9d:62:3e:15:01:ac  .......Z...b>...
00000320  5f:86:74:85:b4:4b:86:40:97:09:10:4e:ca:e2:6d:fa  [email protected].
00000330  2b:32:d0                                         +2.

-> NET_SSH2_MSG_NEWKEYS (since last: 0.0377, network: 0.0001s)


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


-> NET_SSH2_MSG_SERVICE_REQUEST (since last: 0.0009, 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.1134, network: 0.1134s)
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.0002, network: 0s)
00000000  00:00:00:08:75:73:65:72:6e:61:6d:65:00:00:00:0e  ....username....
00000010  73:73:68:2d:63:6f:6e:6e:65:63:74:69:6f:6e:00:00  ssh-connection..
00000020  00:08:70:61:73:73:77:6f:72:64:00:00:00:00:08:70  ..password.....p
00000030  61:73:73:77:6f:72:64                             assword

<- NET_SSH2_MSG_USERAUTH_BANNER (since last: 0.0001, network: 0s)
00000000  00:00:01:5e:22:55:73:65:20:6f:66:20:74:68:69:73  ...^"Use of this
00000010  20:73:79:73:74:65:6d:20:69:73:20:72:65:73:74:72   system is restr
00000020  69:63:74:65:64:20:74:6f:20:61:75:74:68:6f:72:69  icted to authori
00000030  73:65:64:20:75:73:65:72:73:20:6f:6e:6c:79:2e:20  sed users only. 
00000040  55:73:65:72:20:61:63:74:69:76:69:74:79:20:6d:61  User activity ma
00000050  79:20:62:65:20:6d:6f:6e:69:74:6f:72:65:64:20:61  y be monitored a
00000060  6e:64:2f:6f:72:20:72:65:63:6f:72:64:65:64:2e:20  nd/or recorded. 
00000070  41:6e:79:6f:6e:65:20:75:73:69:6e:67:20:74:68:69  Anyone using thi
00000080  73:20:73:79:73:74:65:6d:20:65:78:70:72:65:73:73  s system express
00000090  6c:79:20:63:6f:6e:74:65:6e:74:73:20:74:6f:20:73  ly contents to s
000000a0  75:63:68:20:6d:6f:6e:69:74:6f:72:69:6e:67:20:61  uch monitoring a
000000b0  6e:64:2f:6f:72:20:72:65:63:6f:72:64:69:6e:67:2e  nd/or recording.
000000c0  20:42:45:20:41:44:56:49:53:45:44:3a:20:69:66:20   BE ADVISED: if 
000000d0  70:6f:73:73:69:62:6c:65:20:63:72:69:6d:69:6e:61  possible crimina
000000e0  6c:20:61:63:74:69:76:69:74:79:20:69:73:20:64:65  l activity is de
000000f0  74:65:63:74:65:64:2c:20:74:68:65:73:65:20:61:72  tected, these ar
00000100  65:20:72:65:63:6f:72:64:73:2c:20:61:6c:6f:6e:67  e records, along
00000110  20:77:69:74:68:20:63:65:72:74:61:69:6e:20:70:65   with certain pe
00000120  72:73:6f:6e:61:6c:20:69:6e:66:6f:72:6d:61:74:69  rsonal informati
00000130  6f:6e:2c:20:6d:61:79:20:62:65:20:70:72:6f:76:69  on, may be provi
00000140  64:65:64:20:74:6f:20:6c:61:77:20:65:6e:66:6f:72  ded to law enfor
00000150  63:65:6d:65:6e:74:20:6f:66:66:69:63:69:61:6c:73  cement officials
00000160  22:0a:00:00:00:00                                ".....

<- NET_SSH2_MSG_USERAUTH_FAILURE (since last: 0.0617, network: 0.0616s)
00000000  00:00:00:27:70:75:62:6c:69:63:6b:65:79:2c:70:61  ...'publickey,pa
00000010  73:73:77:6f:72:64:2c:6b:65:79:62:6f:61:72:64:2d  ssword,keyboard-
00000020  69:6e:74:65:72:61:63:74:69:76:65:00              interactive.

-> NET_SSH2_MSG_USERAUTH_REQUEST (since last: 0.0002, network: 0.0001s)
00000000  00:00:00:0f:75:73:72:2d:52:49:54:4d:30:31:35:35  ....user-xxxxxx
00000010  31:39:37:00:00:00:0e:73:73:68:2d:63:6f:6e:6e:65  xxx....ssh-conne
00000020  63:74:69:6f:6e:00:00:00:14:6b:65:79:62:6f:61:72  ction....keyboar
00000030  64:2d:69:6e:74:65:72:61:63:74:69:76:65:00:00:00  d-interactive...
00000040  00:00:00:00:00                                   .....

<- NET_SSH2_MSG_USERAUTH_INFO_REQUEST (60) (since last: 0.0383, network: 0.0382s)
00000000  00:00:00:17:50:61:73:73:77:6f:72:64:20:41:75:74  ....Password Aut
00000010  68:65:6e:74:69:63:61:74:69:6f:6e:00:00:00:22:45  hentication..."E
00000020  6e:74:65:72:20:70:61:73:73:77:6f:72:64:20:66:6f  nter password fo
00000030  72:20:75:73:72:2d:52:49:54:4d:30:31:35:35:31:39  r user-xxxxxx
00000040  37:00:00:00:00:00:00:00:01:00:00:00:09:50:61:73  7............Pas
00000050  73:77:6f:72:64:3a:00                             sword:.

-> NET_SSH2_MSG_USERAUTH_INFO_RESPONSE (61) (since last: 0.0002, network: 0.0001s)
00000000  00:00:00:01:00:00:00:0c:64:75:6d:6d:79:2d:61:6e  ........dummy-an
00000010  73:77:65:72                                      swer

<- NET_SSH2_MSG_USERAUTH_FAILURE (since last: 0.06, network: 0.0599s)
00000000  00:00:00:27:70:75:62:6c:69:63:6b:65:79:2c:70:61  ...'publickey,pa
00000010  73:73:77:6f:72:64:2c:6b:65:79:62:6f:61:72:64:2d  ssword,keyboard-
00000020  69:6e:74:65:72:61:63:74:69:76:65:00              interactive.

奇怪的是,当我在测试服务器内SSH(它的IP被列入白名单)并直接在终端内使用相同的用户名和密码进行SFTP连接时,登录正常,但没有问题,但是通过phpseclib失败,我有也尝试使用Laravel的League / flysystem-sftp,但同样失败。任何人都有任何线索可能有什么问题吗?

更新:

forge@my-server:~/xxxxxx.xxx/public$ sftp [email protected]
"Use of this system is restricted to authorised users only. User activity may be monitored and/or recorded. Anyone using this system expressly contents to such monitoring and/or recording. BE ADVISED: if possible criminal activity is detected, these are records, along with certain personal information, may be provided to law enforcement officials"
Password Authentication
Enter password for usr-xxxxx
Password:
Connected to domain.com.
sftp> ls
sftp> exit

它曾经工作的前一天不知道现在发生了什么,即使SSH / SFTP从我的测试服务器到SFTP服务器(该服务器属于一个外部组织)也失败了,不确定他们端是否有任何更改会验证。

这是从我的测试服务器到sftp服务器的完整sftp连接日志。

forge@my-server:~$ sftp -vvv [email protected]
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "domain.com" port 22
    debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to domain.com [123.123.123.123] port 22.
debug1: Connection established.
debug1: identity file /home/forge/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/forge/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/forge/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/forge/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/forge/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/forge/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/forge/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/forge/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version SSHD
debug1: no match: SSHD
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to domain.com:22 as 'usr-xxxxxxx’
debug3: hostkeys_foreach: reading file "/home/forge/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/forge/.ssh/known_hosts:11
debug3: load_hostkeys: loaded 1 keys from domain.com
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: [email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa,[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes256-ctr
debug2: ciphers stoc: aes256-ctr
debug2: MACs ctos: hmac-sha256,hmac-sha1
debug2: MACs stoc: hmac-sha256,hmac-sha1
debug2: compression ctos: none,zlib
debug2: compression stoc: none,zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes256-ctr MAC: hmac-sha1 compression: none
debug1: kex: client->server cipher: aes256-ctr MAC: hmac-sha1 compression: none
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 4101/8192
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:WFuVGkwSRPO8v/4e7GUFGHcSuciho9kK56LSf7t+Iyc
debug3: hostkeys_foreach: reading file "/home/forge/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/forge/.ssh/known_hosts:11
debug3: load_hostkeys: loaded 1 keys from domain.com
debug3: hostkeys_foreach: reading file "/home/forge/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/forge/.ssh/known_hosts:12
debug3: load_hostkeys: loaded 1 keys from 123.123.123.123
debug1: Host ‘domain.com’ is known and matches the RSA host key.
debug1: Found key in /home/forge/.ssh/known_hosts:11
debug2: bits set: 4098/8192
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug2: key: /home/forge/.ssh/id_rsa (0x559b90cc1010)
debug2: key: /home/forge/.ssh/id_dsa ((nil))
debug2: key: /home/forge/.ssh/id_ecdsa ((nil))
debug2: key: /home/forge/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 53
debug3: input_userauth_banner
"Use of this system is restricted to authorised users only. User activity may be monitored and/or recorded. Anyone using this system expressly contents to such monitoring and/or recording. BE ADVISED: if possible criminal activity is detected, these are records, along with certain personal information, may be provided to law enforcement officials"
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxx /home/forge/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/forge/.ssh/id_dsa
debug3: no such identity: /home/forge/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/forge/.ssh/id_ecdsa
debug3: no such identity: /home/forge/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/forge/.ssh/id_ed25519
debug3: no such identity: /home/forge/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 1
Received disconnect from 123.123.123.123 port 22:11: Certificate Authentication is mandatory. Please provide valid one!
Disconnected from 123.123.123.123 port 22
Connection closed
php laravel phpseclib
1个回答
1
投票

-vvv日志几乎使我想知道服务器是否正在使用多因素身份验证。就像您必须同时提供RSA密钥和密码一样。如果是这样,您应该能够这样实现:

$key = new RSA;
$key->loadKey(file_get_contents('/home/forge/.ssh/id_rsa'));

$sftp = new SFTP(env('SFTP_HOST'));
if (!$sftp->login(env('SFTP_USER'), $key, env('SFTP_PASSWORD'))) {
    echo $sftp->getLog();
}

-vvv日志还表明它正在直接跳至键盘交互式身份验证-甚至没有尝试进行密码身份验证。您可以通过执行$sftp->login(env('SFTP_USER'), ['Password:' => env('SFTP_PASSWORD')])而不是您正在执行的操作来强制phpseclib进行键盘交互。

也许这两个技巧的组合会帮助您。

© www.soinside.com 2019 - 2024. All rights reserved.