<?php

$groupname = "";
$username = "";
$password = "";
$home = "";  // /var/www/$username

function createUser($groupname, $username, $home, $password){
	exec("mkdir " . $home);
	exec("useradd " . $username);
	exec("groupadd " . $groupname);
	exec("passwd " . $username);
	exec("gpasswd -a " . $username . "" . $groupname);
	exec("chown –R " . $username . "" . $home);
	exec("chgrp -R " . $groupname . "" . $home);
	exec("chmod -R g+rw " . $home);
	exec("usermod -d " . $home . "/ " . $username);

	exec("service vsftpd restart");
}

function removeUser($username, $home){
	exec("userdel " . $username);
	exec("rm -rf " . $home);
}

function editUser(){
	$UserFtpName = "testuser";
	$UserFtpPass = "12345678";
	$output = array();

	exec("ssh -t user@192.168.1.10 echo " . $UserFtpName . ":" . $UserFtpPass . " | /usr/bin/sudo /usr/sbin/chpasswd",$output,$status);
	
	if ($status == 0) { // Success - password changed
	   echo 'Password changed. - ';
	}
	else { // Password failed 
	    echo 'Password change failed. - ';
	}

	var_dump($output);
}

?>

Comments

apo2888 için bir cevap yazın Cevabı iptal et

E-posta hesabınız yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Şu HTML etiketlerini ve özelliklerini kullanabilirsiniz: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>