This should work for you.
<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
exit('Login Failed');
}
echo $ssh->read('username@username:~$');
$ssh->write("passwd\n");
echo $ssh->read('(current) UNIX password:');
$ssh->write("oldpassword\n");
echo $ssh->read('New UNIX password:');
$ssh->write("newpassword\n");
echo $ssh->read('Retype new UNIX password:');
$ssh->write("newpassword\n");
echo $ssh->read('passwd: all authentication tokens updated successfully.');
?>
source
share