6

I downloaded phpseclib-0.3.10 from http://phpseclib.sourceforge.net/

My php Version : PHP 5.2.4

OS : CentOS release 6.6

When I run following I am getting "Segmentation fault" at this line $ssh->login('username', 'password')

<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('Net/SSH2.php');
$ssh=new Net_SSH2('servername');
if (!$ssh->login('username', 'password')) {
     exit('Login Failed');
}
echo $ssh->exec('pwd');
?>

I am unable find the reason for this issue. Could you please help me to find the reason for this.

Shi
  • 4,027
  • 1
  • 22
  • 31
  • 1
    You might not want to hear this, but PHP 5.2 is outdated and not supported anymore. Many, many fixes have been done since then; one might have fixed the segmentation fault. – Shi May 14 '15 at 14:14

1 Answers1

0

My guess: either the fsockopen() call or the stream_select() call. You can figure it out by putting die()'s in your code at successive points within login() and the functions called therein.

Looking it up... login() calls _login():

https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1801

_login() calls _connect():

https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1817

eg. before line 964 in Net/SSH2.php add die('this far'). If it says "this far" then try adding it after. If you get a seg fault when it's after but not before that probably means it's the fsockopen that's to blame.

And just keep on doing that until you get the seg fault. Do a die('this far'); before and after the stream_select and just where-ever. And then post the line you're getting it on.

neubert
  • 14,208
  • 21
  • 90
  • 172
  • Thanks neubert for the reply. I did stack trace and I see that following lines throwing Segmentation fault Math_BigInteger->modPow() SSH2.php:1405 openssl_public_encrypt() BigInteger.php:1697 – kranti kumar May 18 '15 at 04:09
  • Can you post a link to your phpinfo()? Maybe put it on a pastebin and post the link. Thanks! – neubert May 19 '15 at 20:19