Esempio n. 1
0
 /**
  * Establish SFTP connection
  * @return bool true when connection success
  * @throws CException if connection fails
  */
 public function connect()
 {
     $this->objSftp = new Net_SFTP($this->host);
     if ($this->objSftp->login($this->username, $this->password)) {
         $this->objSsh = new Net_SSH2($this->host);
         $this->objSsh->login($this->username, $this->password);
         return true;
     } else {
         $this->errorCode = self::ERROR_CONNECTION_FAILED;
         $this->errorMessage = Yii::t('XSFtp.sftp', 'SFtp connection failed!');
         return false;
     }
 }
Esempio n. 2
0
<?php

/**
 * SSH2 libs
 * 
 * @author Radek Hřebeček <*****@*****.**>
 * @copyright  Copyright (c) 2012 Radek Hřebeček (https://github.com/rhrebecek)
 * @license New BSD License
 * @link https://github.com/rhrebecek/SSH2
 *
 * @example
 * 	Working with an object is very simple
 * 		
 * ////////////////////////////////////////////////
 * 
 * 		include 'SSH2.php';
 * 
 * 		$ssh = new \SSH2;
 * 		$ssh->login('root', 'password', 'example.com');
 * 		$ssh->exec('ls --all');
 * 
 * 		echo $ssh->getOutput();
 * 
 * /////////////////////////////////////////////////
 */
include "libs/SSH2.php";
$ssh = new SSH2();
$ssh->login('root', 'password', 'example.com')->exec('ls -all')->getOutputBlackScreen();