我有一个可移植的版本的Apache和php7在Windows phpseclib1.0.7。我想扩展lib以便利用ssh。利用从网站股票脚本 测试PHP SSH2:超过30秒的最大执行时间
<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('-Redacted-');
if (!$ssh->login('-Redacted-', '-Redacted-')) {
exit('Login Failed');
}
echo $ssh->read('[email protected]:~$');
$ssh->write("sudo ls -la\n");
$output = $ssh->read('#[pP]assword[^:]*:|[email protected]:~\$#',
NET_SSH2_READ_REGEX);
echo $output;
if (preg_match('#[pP]assword[^:]*:#', $output)) {
$ssh->write("password\n");
echo $ssh->read('[email protected]:~$');
}
?>
即使缺少信息,则应该抛出一个错误,而是它给了我
PHP Fatal error: Maximum execution time of 30 seconds exceeded in
C:\Users\-Redacted-\Desktop\Apache2.2\htdocs\Net\SSH2.php on line 2358
这里是SSH2.php开始行2351
if (isset($this->keyboard_requests_responses)) {
for ($i = 0; $i < $num_prompts; $i++) {
if (strlen($response) < 4) {
return false;
}
extract(unpack('Nlength', $this->_string_shift($response, 4)));
// prompt - ie. "Password: "; must not be empty
Line 2358---- $prompt = $this->_string_shift($response, $length);
//$echo = $this->_string_shift($response) != chr(0);
foreach ($this->keyboard_requests_responses as $key => $value) {
if (substr($prompt, 0, strlen($key)) == $key) {
$responses[] = $value;
break;
}
}
}
}
没有人有任何想法如何解决?
你可以ping远程主机吗? – apokryfos
是否确定您的服务器ssh open是否打开? –
腻子与远程主机一起工作得很好。 – MoonEater916