So, i'm using SSH lib and everything works fine with simple ssh queries like:
mkdir mydir
but when i'm trying to change user password, it doesn't work, i have copied the same query text in putty, there it work fine. I think it's problem with something else. My user pass code line:
$ssh->SendCommand('echo -e "'.$new_pw.'\\n'.$new_pw.'" | passwd '.$sd[0]['port'].'')
;
Using phpseclib, a pure PHP SSH implementation ,
$ssh->enablePTY();
$ssh->exec('passwd');
$ssh->write("newpw\n");
$ssh->read('password:'); // full string is "Retype new UNIX password:"
$ssh->write("newpw\n");
$ssh->read('success'); // full string is "passwd: password updated successfully"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.