I am using phpseclib in my project. I have installed it and am testing it using the following piece of code which is similar to the example here.
Updated Code:
1 require("Net/SSH2.php");
2
3 if (!class_exists('Net_SSH2')) die("Class Net_SSH2 doesn't exist!");
4
5 $ssh = new Net_SSH2('***'); // the host IP address
6
7 if (!method_exists($ssh, 'Net_SSH2')) die("Net_SSH2 class doesn't have Net_SSH2 method!");
8
9 if (!$ssh->login('***', '***')) { // (verified) username and password
10 echo "LOG: " . $ssh->getLog() . "<br>";
11 exit('Login failed!');
12 }
Code Update 2:
1 require("Net/SSH2.php");
2
3 define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
4
5 if (!class_exists('Net_SSH2')) die("Class Net_SSH2 doesn't exist!");
6
7 $ssh = new Net_SSH2('***'); // the host IP address
8
9 if (!method_exists($ssh, 'Net_SSH2')) die("Net_SSH2 class doesn't have Net_SSH2 method!");
10
11 if (!$ssh->login('***', '***')) { // (verified) username and password
12 echo "LOG: " . $ssh->getLog() . "<br>";
13 echo "ALL ERRORS: ";
14 print_r($ssh->getErrors());
15 echo "<br>LAST ERROR: " . $ssh->getLastError() . "<br>";
16 exit('Login failed!');
17 }
It exits at line # 16. getLog()
gives nothing so it is hard to know where the problem is. I had the login credentials tested using PuTTY. It is not able to login to other servers either. I am not able to understand what is causing the problem.
Any help would be highly appreciated!
I ended up hosting my code on the server (server B) that I was trying to connect. The same code worked in the opposite direction (I could connect to the server A where my code previously was)! I ended up concluding that the server A has environmental issues. I appreciate those were helping me here!