Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.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 净SSH2不工作?_Php_Apache_Authentication_Ssh - Fatal编程技术网

Php 净SSH2不工作?

Php 净SSH2不工作?,php,apache,authentication,ssh,Php,Apache,Authentication,Ssh,我试着在我的网站上添加注册内容,我试着使用net_ssh2来实现这一点,向.htpasswd添加用户,但每当我运行它时,它都会出现一个空白的白色屏幕。但是,如果我删除了所有的ifs,并且没有使用$ssh->exec()的输出分配变量,那么它确实可以工作 这是我的密码: <?php include('Net/SSH2.php'); $ssh = new Net_SSH2('*******'); if (!$ssh->login('******', '*****')) { ex

我试着在我的网站上添加注册内容,我试着使用net_ssh2来实现这一点,向
.htpasswd
添加用户,但每当我运行它时,它都会出现一个空白的白色屏幕。但是,如果我删除了所有的ifs,并且没有使用
$ssh->exec()的输出分配变量,那么它确实可以工作

这是我的密码:

<?php
include('Net/SSH2.php');

$ssh = new Net_SSH2('*******');
if (!$ssh->login('******', '*****')) {
    exit('Internal Server Error');
}

$cat = echo $ssh->exec("cat /etc/.htpasswd");
if (strpos($_POST["user"], $cat) !== false) {
    exit("User exists");
} elseif(strpos($_POST["user"], ';') !== false) {
    exit("Nice try..");
} else {
    $ssh->exec("sudo htpasswd -b /etc/.htpasswd {$_POST["user"]} {$_POST["password"]}");
    $ssh->exec('echo Complete; exit');
}
?>