I'm afraid this question looks trivial, but I'm working on it one entire day and can't understand what happen.
Im using the SSH library phpseclib to connect to a ssh host, and after that, doing a telnet connection
<?php
set_include_path(get_include_path() . "\\" . 'phpseclib');
include('Net/SSH2.php');
$ssh = new Net_SSH2('10.10.10.10');
if (!$ssh->login('user', 'password'))
{
exit('Login Failed');
}
echo $ssh->read('$');
echo "<hr />";
echo $ssh->write("telnet 10.10.20.20
");
echo "<hr />";
echo $ssh->read('User');
echo "<hr />";
echo $ssh->write('admin
');
echo"<hr />";
echo $ssh->read('Password');
$ssh->write('admin
');
?>
Well, debugging it stops after detect User. I think I send the user, but I wait forever for the string Password.
The exit I have in HTML code is the following
Last login: Tue Dec 2 14:06:11 2014 from 10.10.10.2 $1
telnet 10.10.20.20 Telnet escape character is 'off'. Trying 10.10.20.20...
Connected to 10.10.20.20. Escape character is 'off'. ****Hello User1
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\php\pear\phpseclib\Net\SSH2.php on line 2699
Well, note that 1 appears twice, after the line of last login and the Hello User, that was not intentioned.
Well, any ideas?
On the other hand, I tried to use "exec" command, but with not success too.