/**
		 * RemoteApacheTool constructor
		 *
		 * @param string $host SSH Host
		 * @param string $port SSH port
		 * @param string $username SSH login
		 * @param string $password SSH password
		 */
		function __construct ($host, $port, $authinfo)
		{
			parent::__construct();
			
			$this->Authinfo = $authinfo;
			
			// SSH2
			$this->SSH2 = new SSH2();
						
			if ($this->Authinfo["type"] == "password")
				$this->SSH2->AddPassword($this->Authinfo["login"], $this->Authinfo["password"]);
			elseif ($this->Authinfo["type"] == "pubkey")
				$this->SSH2->AddPubkey($this->Authinfo["login"], $this->Authinfo["pubkey_path"], $this->Authinfo["privkey_path"], $this->Authinfo["key_pass"]);
				
			if (!$this->SSH2->Connect($host, $port, $username, $password))
                Core::RaiseWarning("RemoteApacheTool: SSH2 connection failed");
			
			/*
			$this->conf = $this->SSH2->Exec("/bin/cat {$this->ConfPath}");
			if (!$this->conf || !strlen($this->conf)>0)
			{
				$this->RaiseError("Cannot open HTTPD conf!");
				return false;
			}
			*/
		}
示例#2
0
 /**
  * Authenticate user
  *
  * @param string $authmethod
  * @param variable-length argument lists
  */
 public function Auth($authmethod)
 {
     switch ($authmethod) {
         case "password":
             $this->SSHConnection->AddPassword(func_get_arg(1), func_get_arg(2));
             break;
         case "pubkey":
             $this->SSHConnection->AddPubkey(func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
             break;
     }
 }