1

I've a problem with "ssh chpasswd" .. I need to implement the "$password" of register.. Eg.. I've this code..

echo $ssh->exec("sudo sh -c 'echo $user:test | chpasswd'");

When the script is executed, the "$user" of register is created and the password "test" also too.. but this password I need to write on the code, and I don't want this.. I want to implement the "$password" of user register.. eg..

echo $ssh->exec("sudo sh -c 'echo $user:$password | chpasswd'");

Now I tried this mode

$password = mysql_real_escape_string($_POST['password']);
$salt = hash('sha512', $username); //Salt
$password_hash = hash('sha512', $salt.$password);
$password_hash = $_SESSION['password'];
mysql_query("SELECT * FROM `client` WHERE `password`= '$password_hash'");

// ... 

echo $ssh->exec("sudo sh -c 'echo $user:$password_hash | chpasswd'");

but the code is apparently ok.. but doesn't work.. and I tried put this:

$cmd = sprintf( "sudo sh -c 'echo %s:%s | chpasswd'", $user, $password );
var_dump( $cmd );
echo $ssh->exec( $cmd );

but doesn't show me the command to be executed..

I am not able to do this command works.. doesn't create the password when the user register on the website..

Can help me guys.. ?

Regards..

0

You must log in to answer this question.

Browse other questions tagged .