问题
I am currently using laravel(which uses phpseclib) for my project and was having issues with the ssh connection, getting the error Maximum execution time of 60 seconds exceeded
now I know this value can be extended but I should not have to in order to run a simple ls
command.
it seems to be failing in this class phpseclib/Math/BigInteger.php
I have tried every example in the phpseclib documentation, I am still getting the same errors.
I have also tried using exec("ssh -i /path/to/key user@host ls", $out, $code);
and I am able to connect just fine.
I have also testing fsock
and no errors returned, so everything looks good.
$fsock = fsockopen('server', 22);
echo fgets($fsock, 1024);
any ideas on why this is happening?
回答1:
I have solved this, it turns out my openssl library version and header version did not match, this causes phpseclib to use a slower library, which then causes the timeout. as a temporary fix I have modified the following.
here:
starting at line 256
from this :
switch (true) {
case !isset($versions['Header']):
case !isset($versions['Library']):
case $versions['Header'] == $versions['Library']:
define('MATH_BIGINTEGER_OPENSSL_ENABLED', true);
break;
default:
define('MATH_BIGINTEGER_OPENSSL_DISABLE', true);
}
to this:
switch (true) {
case !isset($versions['Header']):
case !isset($versions['Library']):
case $versions['Header'] == $versions['Library']:
define('MATH_BIGINTEGER_OPENSSL_ENABLED', true);
break;
default:
define('MATH_BIGINTEGER_OPENSSL_ENABLE', true);
}
来源:https://stackoverflow.com/questions/23765220/phpseclib-exceeded-max-execution-time