I am attemping to use the phpseclib to change the password of my remote server through its NET_SSH2 functions. Below is what I am using.
<?php
require_once('Net/SSH2.php');
$ssh = new Net_SSH2('server1.server.com');
if (!$ssh->login('user', 'pass')) {
exit('Login Failed');
}
$ssh->write("passwd\n");
$ssh->read('(current) UNIX Password:');
$ssh->write("oldpass\n");
$ssh->read('New password:');
$ssh->write("newpass\n");
$ssh->read('Retype new password:');
$ssh->write("newpass\n");
echo $ssh->read('[prompt]');
?>
Everytime my script just hangs and doesn't seem to do much of anything. Anything I could be doing wrong here?
Here is the documentation on this: http://phpseclib.sourceforge.net/documentation/net.html
strace(1), what are the exact strings that it does read? Why don't you wait for the initial shell prompt? If you add debuggingechostatements, where exactly does it stall?