Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP shell_exec如何更改LINUX密码_Php_Shell Exec - Fatal编程技术网

PHP shell_exec如何更改LINUX密码

PHP shell_exec如何更改LINUX密码,php,shell-exec,Php,Shell Exec,我需要一些认真的帮助。我被锁在服务器外面:某个黑客更改了我的密码。然而,他无法破解根帐户。我仍然有访问权限,但在SSH中没有启用,所以我需要在Linux中访问我的帐户。我只能在服务器上访问HTTP。我想知道是否可以通过PHP更改我的密码 我有一个错误消息sudo requires terminal。你能帮我恢复密码吗 <? $command_exec = 'su root -u root mypwd'; $root_pwd = 'msiamd'; $description = array(

我需要一些认真的帮助。我被锁在服务器外面:某个黑客更改了我的密码。然而,他无法破解根帐户。我仍然有访问权限,但在SSH中没有启用,所以我需要在Linux中访问我的帐户。我只能在服务器上访问HTTP。我想知道是否可以通过PHP更改我的密码

我有一个错误消息sudo requires terminal。你能帮我恢复密码吗

<?
$command_exec = 'su root -u root mypwd';
$root_pwd = 'msiamd';
$description = array(
    0 => array("pipe","r"),
    1 => array("pipe","w"),
    2 => array("file","error-output", "a"
));
$process = proc_open($command_exec,$description,$pipes);
if(is_resource($process))
{
    fwrite($pipes[0],$root_pwd."\r\n");
    fclose($pipes[0]);
    echo stream_get_contents($pipes[1]);
    print_R($pipes);
    fclose($pipes[1]);
    proc_close($process);
}
?>
你试过了吗

string shell_exec ('sudo su [[password]]');
string shell_exec ('passwd [[account]]');
string shell_exec ('[[new-password]]');
string shell_exec ('[[new-password]]');
警告 这是未经测试的,可能不起作用/产生意外后果!使用风险自负


我只在一些简单的事情上使用了shell_exec,从来没有尝试过这样做。

我用php还有哪些其他选项可以重新访问我的服务器谢谢..您的主机不愿意物理访问服务器并启用root SSH登录或重新密码您的登录帐户吗?据我所知,除非您事先对其进行了不同的配置,否则您不能让su或sudo以交互方式请求密码,明确地阻止这样的事情,因为这很容易成为可怜的程序员手中的安全漏洞。远程操作不可用吗?直接启动bash并进行调整更容易。