phpseclib SSH2 write not executing long command

狂风中的少年 提交于 2020-01-06 06:30:15

问题


I am trying to execute an SSH command to a device (firewall). Command is executed when the length is short. When the length is about 1000 characters, command is not being executed.

When I execute the command via putty, that is working as well.

After reading few solutions, I tried to set timeout to 5 seconds. Still, no help.

In the device logs, I can see SSH login and logout. But no activity.

I am using phpseclib ssh version 2.0

$ssh = new SSH2(ip_address);
$ssh->login($user, $password);
$ssh->write($command);
$ssh->setTimeout(5);
$ssh->read()

回答1:


Juddging the source code of the library https://github.com/phpseclib/phpseclib/blob/master/phpseclib/Net/SSH2.php#L4244 we can see, that the waiting time is in-built in the library, so you do not have to set a timeout.

If this doesn't work, you can open an issue on the github, providing your command. IF the library is being supported, you'll get a fix or an answer from the library developers.




回答2:


Issue ended up being in the path between server and the device.



来源:https://stackoverflow.com/questions/55098095/phpseclib-ssh2-write-not-executing-long-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!