Я использую PHPSecLib для отправки команд через SSH на сетевые коммутаторы, что прекрасно работает в большинстве случаев. Мне пришлось сделать несколько модификаций для поддержки другой марки, однако, похоже, что отправка команд через write () приводит к их разделению.
Я никогда не видел ничего подобного, и я не знаю, что его вызывает. Есть ли в PHPSecLib / SSH что-нибудь, что заставляло бы строки командной строки определенной длины?
Вывод командной строки:
configure Entering configuration mode
{master:0}[edit]
LHBR@EVO-HN11-1# set policy-options prefix-list ddosHost 183.24.48.7 255.
LHBR@EVO-HN11-1# ...ix-list ddosHost 183.24.48.7 255.2 55.255.255 ^ syntax error.
{master:0}[edit]
LHBR@EVO-HN11-1# commit configuration check succeeds commit complete
{master:0}[edit]
LHBR@EVO-HN11-1# exit Exiting configuration mode
{master:0}
LHBR@EVO-HN11-1>
Функция:
public function write_msg($msg)
{
for ($i = 0; $i < strlen($msg); $i++)
{
$this->conn->write($msg[$i]);
}
}
public function create_nullroute($ip, $netmask = "255.255.255.255")
{
$this->write_msg("configure\n");
$this->write_msg("set policy-options prefix-list ddosHost " . $ip . " " . $netmask . "\n");
$this->write_msg("commit\n");
// Escape the config mode
$this->conn->write("exit\n");
echo "</br><pre>" . $this->conn->getLog() . "</pre>";
echo $this->conn->read($this->_bashshell);
}
PHPSecLib Log:
-> NET_SSH2_MSG_NEWKEYS (since last: 0.005, network: 0s)<- NET_SSH2_MSG_NEWKEYS (since last: 0, network: 0s)-> NET_SSH2_MSG_SERVICE_REQUEST (since last: 0.0028, 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.5057, network: 0.5056s)
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: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_SUCCESS (since last: 0.2388, network: 0.2387s)-> NET_SSH2_MSG_CHANNEL_OPEN (since last: 0.0001, 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 .....@.
<- NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION (since last: 0.2093, network: 0.2092s)
00000000 00:00:00:01:00:00:00:00:00:00:00:00:00:00:80:00 ................
-> NET_SSH2_MSG_CHANNEL_REQUEST (since last: 0.0001, network: 0s)
00000000 00:00:00:00:00:00:00:07:70:74:79:2d:72:65:71:01 ........pty-req.
00000010 00:00:00:05:76:74:31:30:30:00:00:00:50:00:00:00 ....vt100...P...
00000020 18:00:00:00:00:00:00:00:00:00:00:00:01:00 ..............
<- NET_SSH2_MSG_CHANNEL_SUCCESS (since last: 0.2233, network: 0.2232s)
00000000 00:00:00:01 ....
-> NET_SSH2_MSG_CHANNEL_REQUEST (since last: 0.0001, network: 0s)
00000000 00:00:00:00:00:00:00:05:73:68:65:6c:6c:01 ........shell.
<- NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST (since last: 0.2153, network: 0.2153s)
00000000 00:00:00:01:00:20:00:00 ..... ..
<- NET_SSH2_MSG_CHANNEL_SUCCESS (since last: 0.0001, network: 0s)
00000000 00:00:00:01 ....
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0158, network: 0.0157s)
00000000 00:00:00:01:00:00:00:32:2d:2d:2d:20:4a:55:4e:4f .......2--- JUNO
00000010 53:20:31:32:2e:33:52:33:2e:34:20:62:75:69:6c:74 S 12.3R3.4 built
00000020 20:32:30:31:33:2d:30:36:2d:31:34:20:30:30:3a:30 2013-06-14 00:0
00000030 36:3a:33:34:20:55:54:43:0d:0a 6:34 UTC..
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.6052, network: 0.6051s)
00000000 00:00:00:01:00:00:00:0c:7b:6d:61:73:74:65:72:3a ........{master:
00000010 30:7d:0d:0a 0}..
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0016, network: 0.0015s)
00000000 00:00:00:01:00:00:00:11:4c:48:42:52:40:45:56:4f ........LHBR@EVO
00000010 2d:48:4e:31:31:2d:31:3e:20 -HN11-1>
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000 00:00:00:00:00:00:00:18:73:65:74:20:63:6c:69:20 ........set cli
00000010 73:63:72:65:65:6e:2d:6c:65:6e:67:74:68:20:30:0a screen-length 0.
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.207, network: 0.207s)
00000000 00:00:00:01:00:00:00:01:73 ........s
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0015, network: 0.0014s)
00000000 00:00:00:01:00:00:00:01:65 ........e
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0015, network: 0.0015s)
00000000 00:00:00:01:00:00:00:01:74 ........t
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0047, network: 0.0046s)
00000000 00:00:00:01:00:00:00:01:20 ........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0014, network: 0.0014s)
00000000 00:00:00:01:00:00:00:01:63 ........c
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0025, network: 0.0024s)
00000000 00:00:00:01:00:00:00:01:6c ........l
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0015, network: 0.0015s)
00000000 00:00:00:01:00:00:00:01:69 ........i
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0039, network: 0.0039s)
00000000 00:00:00:01:00:00:00:01:20 ........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0016, network: 0.0015s)
00000000 00:00:00:01:00:00:00:01:73 ........s
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0021, network: 0.002s)
00000000 00:00:00:01:00:00:00:01:63 ........c
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0016, network: 0.0015s)
00000000 00:00:00:01:00:00:00:01:72 ........r
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0014, network: 0.0014s)
00000000 00:00:00:01:00:00:00:01:65 ........e
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0017, network: 0.0017s)
00000000 00:00:00:01:00:00:00:01:65 ........e
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0047, network: 0.0046s)
00000000 00:00:00:01:00:00:00:01:6e ........n
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0002, network: 0.0001s)
00000000 00:00:00:01:00:00:00:01:2d ........-
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000 00:00:00:01:00:00:00:01:6c ........l
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:01:00:00:00:01:65 ........e
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0009, network: 0.0009s)
00000000 00:00:00:01:00:00:00:01:6e ........n
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0016, network: 0.0016s)
00000000 00:00:00:01:00:00:00:01:67 ........g
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0022, network: 0.0021s)
00000000 00:00:00:01:00:00:00:01:74 ........t
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0016, network: 0.0015s)
00000000 00:00:00:01:00:00:00:01:68 ........h
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0041, network: 0.004s)
00000000 00:00:00:01:00:00:00:01:20 ........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0016, network: 0.0015s)
00000000 00:00:00:01:00:00:00:01:30 ........0
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0048, network: 0.0047s)
00000000 00:00:00:01:00:00:00:01:20 ........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0023, network: 0.0022s)
00000000 00:00:00:01:00:00:00:02:0d:0a ..........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0048, network: 0.0048s)
00000000 00:00:00:01:00:00:00:18:53:63:72:65:65:6e:20:6c ........Screen l
00000010 65:6e:67:74:68:20:73:65:74:20:74:6f:20:30:0d:0a ength set to 0..
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0021, network: 0.002s)
00000000 00:00:00:01:00:00:00:02:0d:0a ..........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0043, network: 0.0043s)
00000000 00:00:00:01:00:00:00:0c:7b:6d:61:73:74:65:72:3a ........{master:
00000010 30:7d:0d:0a 0}..
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000 00:00:00:01:00:00:00:11:4c:48:42:52:40:45:56:4f ........LHBR@EVO
00000010 2d:48:4e:31:31:2d:31:3e:20 -HN11-1>
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000 00:00:00:00:00:00:00:01:63 ........c
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000 00:00:00:00:00:00:00:01:6f ........o
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6e ........n
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:66 ........f
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:69 ........i
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:67 ........g
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:75 ........u
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:72 ........r
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:65 ........e
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:0a .........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:73 ........s
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:65 ........e
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:74 ........t
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:20 ........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:70 ........p
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6f ........o
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6c ........l
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:69 ........i
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:63 ........c
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:79 ........y
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:2d ........-
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6f ........o
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:70 ........p
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:74 ........t
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:69 ........i
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6f ........o
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6e ........n
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:73 ........s
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:20 ........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:70 ........p
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:72 ........r
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:65 ........e
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:66 ........f
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:69 ........i
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:78 ........x
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:2d ........-
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6c ........l
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:69 ........i
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:73 ........s
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:74 ........t
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:20 ........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:64 ........d
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:64 ........d
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6f ........o
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:73 ........s
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:48 ........H
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6f ........o
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:73 ........s
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:74 ........t
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:20 ........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:31 ........1
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:38 ........8
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:35 ........5
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:2e .........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:31 ........1
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:36 ........6
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:2e .........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:38 ........8
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:34 ........4
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:2e .........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:37 ........7
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:30 ........0
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:20 ........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:32 ........2
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:35 ........5
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:35 ........5
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:2e .........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:32 ........2
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:35 ........5
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:35 ........5
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:2e .........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:32 ........2
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:35 ........5
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:35 ........5
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:2e .........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:32 ........2
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:35 ........5
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:35 ........5
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:0a .........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:63 ........c
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6f ........o
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6d ........m
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:6d ........m
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:69 ........i
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:74 ........t
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:01:0a .........
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:05:65:78:69:74:0a ........exit.
Вы можете попробовать бросить некоторые $ssh->read()
там. По моему опыту, если вы просто отправляете команду за командой без выполнения каких-либо операций read (), то вы можете отправлять их слишком быстро, прежде чем предыдущая команда сможет выполнить.
Короткий ответ:
Это всего лишь предположение, но вместо того, чтобы делать $this->conn->write("configure\n");
попробуйте написать один символ за раз. например.
$cmd = "configure\n";
for ($i = 0; $i < strlen($cmd); $i++) {
$this->conn->write($cmd[$i]);
}
Длинный ответ:
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000 00:00:00:00:00:00:00:0a:63:6f:6e:66:69:67:75:72 ........configur
00000010 65:0a e.
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.1027, network: 0.1026s)
00000000 00:00:00:01:00:00:00:01:63 ........c
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0012, network: 0.0011s)
00000000 00:00:00:01:00:00:00:08:6f:6e:66:69:67:75:72:65 ........onfigure
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0047, network: 0.0046s)
00000000 00:00:00:01:00:00:00:01:20 ........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0118, network: 0.0118s)
00000000 00:00:00:01:00:00:00:02:0d:0a ..........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0015, network: 0.0015s)
00000000 00:00:00:01:00:00:00:1d:45:6e:74:65:72:69:6e:67 ........Entering
00000010 20:63:6f:6e:66:69:67:75:72:61:74:69:6f:6e:20:6d configuration m
00000020 6f:64:65:0d:0a ode..
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0019, network: 0.0018s)
00000000 00:00:00:01:00:00:00:02:0d:0a ..........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0013, network: 0.0013s)
00000000 00:00:00:01:00:00:00:23:7b:6d:61:73:74:65:72:3a .......#{master:
00000010 30:7d:5b:65:64:69:74:5d:0d:0a:4c:48:42:52:40:45 0}[edit]..LHBR@E
00000020 56:4f:2d:48:4e:31:31:2d:31:23:20 VO-HN11-1#
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s)
00000000 00:00:00:00:00:00:00:45:73:65:74:20:70:6f:6c:69 .......Eset poli
00000010 63:79:2d:6f:70:74:69:6f:6e:73:20:70:72:65:66:69 cy-options prefi
00000020 78:2d:6c:69:73:74:20:64:64:6f:73:48:6f:73:74:20 x-list ddosHost
00000030 31:38:35:2e:31:36:2e:38:34:2e:37:30:20:32:35:35 186.26.81.23 255
00000040 2e:32:35:35:2e:32:35:35:2e:32:35:35:0a .255.255.255.
-> NET_SSH2_MSG_CHANNEL_DATA (since last: 0, network: 0s)
00000000 00:00:00:00:00:00:00:07:63:6f:6d:6d:69:74:0a ........commit.
Таким образом, сервер отправляет обратно каждую команду после ее отправки. Что интересно, это то, что он делает это совершенно случайно. Как и в случае с configure, который отправляется как один пакет, ответ, который вы получаете, состоит в том, что он разделяется на два пакета.
После этого вы отправляете следующие две команды, с которыми сервер ничего не делает. Это не повторяет их или что-то еще. И тогда связь просто закрывается.
Это поднимает пару вопросов.
$this->conn->read()
после этих команд. Ты? Если так, то код в исходном сообщении не актуален.Вывод CLI, который вы опубликовали, не совпадает с выводом в журналах phpseclib. Вывод, который произвел бы phpseclibs, выглядит следующим образом:
2--- JUNOS 12.3R3.4 built 2013-06-14 00:06:34 UTC
{master:0}
biss@EVO-HN11-1> set cli screen-length 0
Screen length set to 0
{master:0}
LHBR@EVO-HN1-1> configure
Entering configuration mode
#{master:0}[edit]
LHBR@EVO-HN11-1#
Таким образом, в вашем сообщении есть определенные расхождения, тем не менее, у меня есть одна идея, основанная на том, что вы опубликовали до сих пор.
Вместо того чтобы делать $this->conn->write("configure\n");
попробуйте написать один символ за раз. например.
$cmd = "configure\n";
for ($i = 0; $i < strlen($cmd); $i++) {
$this->conn->write($cmd[$i]);
}