Answer the question
In order to leave comments, you need to log in
How to change root password on Linux using ssh2?
Hello. How to change root password on Linux using ssh2? I searched on Google, but alas, I did not find anything.
My code:
$connection = ssh2_connect('0.0.0.0', 22);
ssh2_auth_password($connection, 'root', 'pass');
$stream = ssh2_exec($connection, 'passwd 123321 \n 123321 \n');
stream_set_blocking($stream, true);
$data = '';
while($buffer = fread($stream, 4096)) {
$data .= $buffer;
}
echo $data."<hr/>";
fclose($stream);
Answer the question
In order to leave comments, you need to log in
Damn, what are you doing there at all?
Firstly, php must have access to the root account, which is not really feng shui.
well, let's say your apache is added to group 0. ok now, when the system is hacked, it's not the site that gets into a vulnerability, but the whole system as a whole. well, let
's change the passwd password in the console. What for to write a bunch of code?
Ladnov so impatient but you do not know how to use? exec
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question